home *** CD-ROM | disk | FTP | other *** search
/ Aminet 45 / Aminet 45 (2001)(GTI - Schatztruhe)[!][Oct 2001].iso / Aminet / util / misc / ReportPlus.lha / reportplus / source / rp.c < prev    next >
Encoding:
C/C++ Source or Header  |  2001-08-21  |  108.3 KB  |  3,050 lines

  1. /* $Filename:    ReportPlus/Source/rp.c
  2.  * $VER:         Report+ 5.02
  3.  * $Description: Multipurpose utility
  4.  *
  5.  * © Copyright 2001 James R. Jacobs. Freely distributable.
  6.  *        _
  7.  *       //      -=AMIGA=-
  8.  *      //
  9.  * _   //
  10.  * \\ //
  11.  *  \X/
  12.  
  13. #INCLUDES -------------------------------------------------------------- */
  14.  
  15. /* #include <assert.h> */
  16.  
  17. #include <exec/types.h>
  18. #include <exec/alerts.h>
  19. #include <exec/nodes.h>
  20. #include <exec/memory.h>
  21. #include <exec/execbase.h>
  22. #include <proto/exec.h>
  23. #include <intuition/intuition.h>
  24. #include <clib/intuition_protos.h>
  25. #include <intuition/gadgetclass.h>
  26. #include <libraries/gadtools.h>
  27. #include <clib/gadtools_protos.h>
  28. #include <workbench/workbench.h> /* struct DiskObject */
  29. #include <libraries/asl.h>
  30. #include <proto/asl.h>
  31. #include <dos/dos.h>
  32. #include <dos/dostags.h>
  33. #include <dos/dosextens.h>
  34. #include <proto/dos.h>
  35. #include <diskfont/diskfont.h>
  36. #include <proto/diskfont.h>
  37. #include <graphics/gfx.h>
  38. #include <graphics/displayinfo.h>
  39. #include <graphics/gels.h>
  40. #include <clib/graphics_protos.h>
  41. #include <utility/tagitem.h>
  42. #include <proto/utility.h>
  43. #include <workbench/icon.h>
  44. #include <clib/icon_protos.h>
  45. #include <clib/alib_protos.h>
  46. #include <resources/battmem.h>
  47. #include <resources/battmembitsamiga.h>
  48. #include <resources/battmembitsshared.h>
  49.  
  50. #define ALL_REACTION_CLASSES
  51. #define ALL_REACTION_MACROS
  52. #include <reaction/reaction.h>
  53. #include <clib/alib_protos.h>
  54. #include <clib/texteditor_protos.h>
  55. #include <gadgets/texteditor.h>
  56. #include <pragmas/texteditor_pragmas.h>
  57.  
  58. #define GID_0_LY1   0
  59. #define GID_0_BU1   1 // the function buttons must start from GID_O_BU1,
  60. #define GID_0_BU2   2 // and must all be consecutive.
  61. #define GID_0_BU3   3
  62. #define GID_0_BU4   4
  63. #define GID_0_BU5   5
  64. #define GID_0_BU6   6
  65. #define GID_0_BU7   7
  66. #define GID_0_BU8   8
  67. #define GID_0_BU9   9
  68. #define GID_0_BU10 10
  69. #define GID_0_BU11 11
  70. #define GID_0_BU12 12
  71. #define GID_0_ST1  13
  72. #define GIDS_0     GID_0_ST1
  73.  
  74. #include <ctype.h>
  75. #include <stdio.h>          /* FILE, printf() */
  76. #include <stdlib.h>         /* EXIT_SUCCESS, EXIT_FAILURE */
  77. #include <string.h>
  78. #include "rp.h"
  79. #include "boards.h"
  80.  
  81. #define FUNCTIONS  12
  82.  
  83. #define SCAN_GRAVE  0
  84.  
  85. #define ABOUTXPIXEL     312
  86. #define ABOUTYPIXEL      98
  87.  
  88. #ifdef __STORM__
  89.    #pragma chip
  90. #endif
  91.  
  92. enum
  93. {   GID_MAIN = 0,
  94.     GID_TEXTEDITOR1,
  95.     GID_TEXTEDITOR2,
  96.     GID_TEXTEDITOR3,
  97.     GID_TEXTEDITOR4,
  98.     GID_TEXTEDITOR5,
  99.     GID_TEXTEDITOR6,
  100.     GID_TEXTEDITOR7,
  101.     GID_TEXTEDITOR8,
  102.     GID_TEXTEDITOR9,
  103.     GID_TEXTEDITOR10,
  104.     GID_TEXTEDITOR11,
  105.     GID_TEXTEDITOR12,
  106.     GID_TEXTEDITOR13,
  107.     GID_TEXTEDITOR14,
  108.     GID_DOWN,
  109.     GID_UP,
  110.     GID_OK,
  111.     GID_LAST
  112. };
  113.  
  114. MODULE UWORD chip PubAboutData[132] =
  115. {   0xFFFF,0xFFFF,0xFFE0,
  116.     0xFFFF,0xFFFF,0xFFE0,
  117.     0xFFFF,0xFFFF,0xFFE0,
  118.     0xFFFF,0xFFFF,0xFFE0,
  119.     0xFBFF,0x8FFF,0xFFE0,
  120.     0xFBFF,0x8FFF,0xFFE0,
  121.     0xCA7F,0x07FF,0xFFE0,
  122.     0xCA7F,0x07FF,0xFFE0,
  123.     0xF1FE,0x03FF,0xFFE0,
  124.     0xF1FE,0x03FF,0xFFE0,
  125.     0xCA7C,0x21FF,0xF7E0,
  126.     0xCA7C,0x21FF,0xF7E0,
  127.     0xFBF8,0x70FF,0x3660,
  128.     0xFBF8,0x70FF,0x3660,
  129.     0xFFF0,0xF87F,0xC1E0,
  130.     0xFFF0,0xF87F,0xC1E0,
  131.     0x87E0,0x0000,0x0020,
  132.     0x87E0,0x0000,0x0020,
  133.     0xC3C0,0x3E1F,0xC1E0,
  134.     0xC3C0,0x3E1F,0xC1E0,
  135.     0xE187,0xC70F,0x3660,
  136.     0xE187,0xC70F,0x3660,
  137.     0xF00F,0xF887,0xF7E0,
  138.     0xF00F,0xF887,0xF7E0,
  139.     0xF81F,0xFF03,0xFFE0,
  140.     0xF81F,0xFF03,0xFFE0,
  141.     0xFC3F,0xFFE1,0xFFE0,
  142.     0xFC3F,0xFFE1,0xFFE0,
  143.     0xFFFF,0xFFFF,0xFFE0,
  144.     0xFFFF,0xFFFF,0xFFE0,
  145.     0xE1C8,0xDC38,0x6EE0,
  146.     0xE1C8,0xDC38,0x6EE0,
  147.     0xDDB6,0xDBF7,0x66E0,
  148.     0xDDB6,0xDBF7,0x66E0,
  149.     0xC1B6,0xDB30,0x6AE0,
  150.     0xC1B6,0xDB30,0x6AE0,
  151.     0xDDBE,0xDBB7,0x6CE0,
  152.     0xDDBE,0xDBB7,0x6CE0,
  153.     0xDDBE,0xD877,0x6EE0,
  154.     0xDDBE,0xD877,0x6EE0,
  155.     0xFFFF,0xFFFF,0xFFE0,
  156.     0xFFFF,0xFFFF,0xFFE0,
  157.     0xFFFF,0xFFFF,0xFFE0,
  158.     0xFFFF,0xFFFF,0xFFE0
  159. };
  160. #ifdef __STORM__
  161.    #pragma chip
  162. #endif
  163.  
  164. AGLOBAL struct NewGadget Gadget =
  165. {   0, 0,                                   /* left-x, top-y */
  166.     0, 0,                                   /* width, height */
  167.     0,                                      /* text */
  168.     NULL,                                   /* font */
  169.     NULL,                                   /* gadget ID */
  170.     NULL,                                   /* flags */
  171.     NULL,                                   /* visual info */
  172.     NULL                                    /* user data */
  173. };
  174.  
  175. #define ABOUTLINES      5
  176. #define ABOUTSHADOW BLACK
  177. #define ABOUTSHINE  WHITE
  178.  
  179. MODULE STRPTR FunctionDesc[FUNCTIONS + 2] =
  180. {   // Edit
  181.     "Bug report",         // 1
  182.     "Aminet readme",      // 2
  183.     "Autodoc",            // 4
  184.     "Battery-backed RAM", // 9
  185.     "AGDB review",        // 1
  186.     // View
  187.     "Manufacturer IDs",   // 5
  188.     "IFF FORMs",          // 6
  189.     // Process
  190.     "EOLs/tabs",          // 7
  191.     "Icons",              // 12
  192.     // Report
  193.     "Path size",          // 8
  194.     "System files",       // 10
  195.     // Conduct
  196.     "ACSE test",          // 3
  197.     // (default)
  198.     TITLEBARTEXT
  199. };
  200.  
  201. MODULE struct
  202. {   WORD   x, y;
  203.     STRPTR text;
  204. } about[ABOUTLINES + 1] =
  205. {   {80,  27, TITLEBARTEXT,           },
  206.     {80,  35, "Tuesday 21 August 2001"},
  207.     {80,  43, "© 2001 Amigan Software"},
  208.     {80,  59, "By James R. Jacobs"    },
  209.     {80,  75, "Kickstart: "           },
  210.     {80,  83, "Workbench: "           }
  211. };
  212. #define MENUENTRIES 13
  213. MODULE struct NewMenu NewMenu[MENUENTRIES] =
  214. {   { NM_TITLE, "Project",       0 , 0,               0, 0},
  215.     {  NM_ITEM, "New",          "N", NM_ITEMDISABLED, 0, 0},
  216.     {  NM_ITEM, "Open...",      "O", NM_ITEMDISABLED, 0, 0},
  217.     {  NM_ITEM, NM_BARLABEL,     0 , 0,               0, 0},
  218.     {  NM_ITEM, "Save",         "S", NM_ITEMDISABLED, 0, 0},
  219.     {  NM_ITEM, "Save As...",   "O", NM_ITEMDISABLED, 0, 0},
  220.     {  NM_ITEM, NM_BARLABEL,     0 , 0,               0, 0},
  221.     {  NM_ITEM, "Quit Report+", "Q", 0,               0, 0},
  222.     { NM_TITLE, "Help",          0 , 0,               0, 0},
  223.     {  NM_ITEM, "Manual...",    "M", 0,               0, 0},
  224.     {  NM_ITEM, NM_BARLABEL,     0 , 0,               0, 0},
  225.     {  NM_ITEM, "About...",     "?", 0,               0, 0},
  226.     {   NM_END, NULL,            0 , 0,               0, 0}
  227. };
  228.  
  229. MODULE void clearkybd(void);
  230. MODULE void menu(void);
  231. MODULE void parsewb(void);
  232. MODULE void eachwildcard(STRPTR subpattern);
  233. MODULE void menu_loop(ULONG gid);
  234.  
  235. int CXBRK(void) { return(0); }    /* Disable SAS/C Ctrl-C handling */
  236. int chkabort(void) { return(0); } /* really */
  237.  
  238. MODULE  struct Window*           AboutWindowPtr  = NULL;
  239. AGLOBAL struct Library          *WindowBase      = NULL,
  240.                                 *LayoutBase      = NULL,
  241.                                 *ButtonBase      = NULL,
  242.                                 *TextEditorBase  = NULL,
  243.                                 *LabelBase       = NULL,
  244.                                 *ListBrowserBase = NULL,
  245.                                 *ChooserBase     = NULL,
  246.                                 *StringBase      = NULL,
  247.                                 *CheckBoxBase    = NULL,
  248.                                 *BoardsBase      = NULL,
  249.                                 *BitMapBase      = NULL;
  250. AGLOBAL ABOOL                   done             = FALSE,
  251.                                 fillwindows      = FALSE,
  252.                                 stop             = FALSE;
  253. AGLOBAL TEXT                    asldir[VLONGFIELD + 1],
  254.                                 aslresult[VLONGFIELD + 1],
  255.                                 IOBuffer[LONGESTFIELD + 1],
  256.                                 globalname[VLONGFIELD + 1],
  257.                                 string[4096 + 1],
  258.                                 weekdaystring[LEN_DATSTRING],
  259.                                 datestring[LEN_DATSTRING],
  260.                                 timestring[LEN_DATSTRING];
  261. AGLOBAL SBYTE                   page             = 0,
  262.                                 closer           = 0;
  263. AGLOBAL ULONG                   fillcolour,
  264.                                 offset,
  265.                                 wbval,
  266.                                 signal;
  267. AGLOBAL ABOOL                   BattBuffer[96];
  268. AGLOBAL struct Library*         IconBase         = NULL;
  269. AGLOBAL struct Menu*            MenuPtr          = NULL;
  270. AGLOBAL struct Screen*          ScreenPtr        = NULL;
  271. AGLOBAL struct Window*          MainWindowPtr    = NULL;
  272. AGLOBAL struct VisualInfo*      VisualInfoPtr    = NULL;
  273. AGLOBAL struct ExAllData*       EADataPtr        = NULL;
  274. AGLOBAL struct Gadget          *BU99_Right       = NULL,
  275.                                *ST99_Output      = NULL,
  276.                                *BU99_OutputASL   = NULL,
  277.                                *CB99_Log         = NULL,
  278.                                *BU99_Update      = NULL,
  279.                                *BU99_Stop        = NULL,
  280.                                *BU99_TextEditor  = NULL,
  281.                                *GListPtr         = NULL,
  282.                                *PrevGadPtr       = NULL;
  283. AGLOBAL struct List             EmptyList;
  284. AGLOBAL struct SharedStruct shared =
  285. {   TRUE, 0,
  286.     "", "", "", "", "", ""
  287. };
  288.  
  289. IMPORT struct ExecBase*     SysBase;
  290. // from f1.c
  291. IMPORT struct ReportStruct  report;
  292. // from f2.c
  293. IMPORT struct AminetStruct  aminet;
  294. IMPORT        Object*       Window2Object;
  295. // from f3.c
  296. IMPORT ABOOL                certified;
  297. // from f4.c
  298. IMPORT struct AutodocStruct autodoc;
  299. IMPORT UBYTE*               StarBufferPtr[MAXELEMENTS + 1];
  300. IMPORT ULONG                StarBufferSize[MAXELEMENTS + 1],
  301.                             returncode,
  302.                             inputs;
  303. // from f6.c
  304. IMPORT struct IFFStruct     iff;
  305. // from f7.c
  306. IMPORT struct Gadget*       TE71_Status;
  307. // from f9.c
  308. IMPORT struct Library*      BattMemBase;
  309. // from f11.c
  310. IMPORT struct AGDBStruct    agdb;
  311. // from f12.c
  312. IMPORT struct IconStruct    icon;
  313. IMPORT struct Gadget*       icon_gadgets[GIDS_12 + 1];
  314. IMPORT        Object*       Window12Object;
  315. IMPORT ABOOL                quit;
  316.  
  317. MODULE struct Gadget*          te_gadgets[MAXELEMENTS + 1];
  318. MODULE STRPTR                  textBuffer[MAXELEMENTS + 1];
  319. MODULE WORD                    windowx[FUNCTIONS + 1],
  320.                                windowy[FUNCTIONS + 1];
  321. MODULE TEXT                    pubscreen[256 + 1];
  322. MODULE WORD                    xsize,
  323.                                ysize;
  324. MODULE ULONG                   elements,
  325.                                ksval;
  326. MODULE        Object*          Window0Object;
  327. MODULE struct Gadget*          gadgets[GIDS_0 + 1];
  328. MODULE struct RDArgs*          ArgsPtr           = NULL;
  329. MODULE struct TextFont*        FontPtr           = NULL;
  330. MODULE struct WBArg*           WBArg             = NULL;
  331. MODULE struct WBStartup*       WBMsg             = NULL;
  332. MODULE struct ASLBase*         ASLBase         = NULL;
  333. MODULE struct DiskFontBase*    DiskFontBase    = NULL;
  334. MODULE struct Library*         GadToolsBase    = NULL;
  335. MODULE struct IntuitionBase*   IntuitionBase   = NULL;
  336. MODULE struct Library*         VersionBase     = NULL;
  337. MODULE struct TextAttr         Topaz8 =
  338. {    (STRPTR) "topaz.font", 8, FS_NORMAL, FPF_ROMFONT | FPF_DESIGNED
  339. }, /* "topaz.font" is case-sensitive */ WormWars8 =
  340. {    (STRPTR) "WormWars.font", 8, FS_NORMAL, FPF_DISKFONT | FPF_DESIGNED
  341. };
  342. MODULE struct Image
  343. PubAbout =
  344. {   0, 0,
  345.     43, 44, 1,
  346.     PubAboutData,
  347.     0x1, 3,
  348.     NULL
  349. };
  350. MODULE  struct EasyStruct       EasyStruct =
  351. {   sizeof(struct EasyStruct),
  352.     0,
  353.     "Report+: Error",
  354.     NULL,
  355.     "Quit"
  356. };
  357.  
  358. /* FUNCTIONS -------------------------------------------------------------- */
  359.  
  360. int main(int argc, char** argv)
  361. {   UWORD  i;
  362.     SLONG  args[12] = { 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L };
  363.     BPTR   OldDir;
  364.     SLONG  number = 0, hostid = 7;
  365.     BPTR   ConfigHandle = NULL;
  366.  
  367.     /* Start of program.
  368.  
  369.     version embedding into executable */
  370.  
  371.     if (0) /* that is, never */
  372.         Printf("$VER: Report+ 5.02 (21.8.2001)"); /* this is always d.m.y format */
  373.  
  374.     /* Check for OS3.5+... */
  375.     if (!(IntuitionBase = (struct IntuitionBase *) OpenLibrary("intuition.library", 40L)))
  376.     {   Printf("Report+: Need AmigaOS 3.5+!\n");
  377.         cleanexit(EXIT_FAILURE);
  378.     }
  379.     if ((ksval = SysBase->LibNode.lib_Version) < 40L)
  380.     {   Printf("Report+: Need AmigaOS 3.5+!\n");
  381.         cleanexit(EXIT_FAILURE);
  382.     }
  383.     if (!(VersionBase = (struct Library *) OpenLibrary("version.library", 0L)))
  384.         rq("Can't open version.library!");
  385.     wbval = VersionBase->lib_Version;
  386.     CloseLibrary((struct Library *) VersionBase);
  387.     VersionBase = NULL;
  388.     if (wbval < 44)
  389.     {   Printf("Report+: Need AmigaOS 3.5+!\n");
  390.         cleanexit(EXIT_FAILURE);
  391.     }
  392.  
  393.     if (!(GadToolsBase = (struct Library *) OpenLibrary("gadtools.library", 38L)))
  394.         rq("Can't open GadTools.library V38+!");
  395.     if (!(ASLBase = (struct ASLBase *) OpenLibrary("asl.library", 0L)))
  396.         rq("Can't open ASL.library!");
  397.     if (
  398.         (DiskFontBase = (struct DiskFontBase *) OpenLibrary("diskfont.library", 0L))
  399.     &&  (FontPtr = OpenDiskFont(&WormWars8))
  400.        )
  401.     {   Gadget.ng_TextAttr = (struct TextAttr *) &WormWars8;
  402.     } elif (!(FontPtr = OpenFont(&Topaz8)))
  403.     {   rq("Can't open fonts!");
  404.     } else
  405.     {   Gadget.ng_TextAttr = (struct TextAttr *) &Topaz8;
  406.     }
  407.  
  408.     if (!(ButtonBase      = OpenLibrary("gadgets/button.gadget", 44)))
  409.                        rq("OpenLibrary(\"gadgets/button.gadget\") failed!");
  410.     if (!(CheckBoxBase    = OpenLibrary("gadgets/checkbox.gadget", 44)))
  411.                        rq("OpenLibrary(\"gadgets/checkbox.gadget\") failed!");
  412.     if (!(ChooserBase     = OpenLibrary("gadgets/chooser.gadget", 44)))
  413.                        rq("OpenLibrary(\"gadgets/chooser.gadget\") failed!");
  414.     if (!(LabelBase       = OpenLibrary("images/label.image", 44)))
  415.                        rq("OpenLibrary(\"images/label.image\") failed!");
  416.     if (!(LayoutBase      = OpenLibrary("gadgets/layout.gadget", 44)))
  417.                        rq("OpenLibrary(\"gadgets/layout.gadget\") failed!");
  418.     if (!(ListBrowserBase = OpenLibrary("gadgets/listbrowser.gadget", 0)))
  419.                        rq("OpenLibrary(\"gadgets/listbrowser.gadget\") failed!");
  420.     if (!(StringBase      = OpenLibrary("gadgets/string.gadget", 44)))
  421.                        rq("OpenLibrary(\"gadgets/string.gadget\") failed!");
  422.     if (!(TextEditorBase  = OpenLibrary("gadgets/texteditor.gadget", 0)))
  423.                        rq("OpenLibrary(\"gadgets/texteditor.gadget\") failed!");
  424.     if (!(WindowBase      = OpenLibrary("window.class", 44)))
  425.                        rq("OpenLibrary(\"window.class\") failed!");
  426.     if (!(BitMapBase      = OpenLibrary("images/bitmap.image", 44)))
  427.                        rq("OpenLibrary(\"images/bitmap.image\") failed!");
  428.     if (!(IconBase        = OpenLibrary("icon.library", 44L)))
  429.                        rq("Need icon.library V44+!");
  430.           BoardsBase      = OpenLibrary("boards.library", 0L);
  431.  
  432.     pubscreen[0] = 0;
  433.     NewList(&EmptyList);
  434.     if (!(EADataPtr = AllocVec(2048, MEMF_CLEAR | MEMF_PUBLIC)))
  435.     {   rq("Out of memory!");
  436.     }
  437.  
  438.     report_init();    // f1
  439.     aminet_init();    // f2
  440.     autodoc_init();   // f4
  441.     size_init();      // f8
  442.     batt_init();      // f9
  443.     files_init();     // f10
  444.     newagdb(FALSE);   // f11
  445.     /* those must be done before we handle CLI arguments */
  446.  
  447.     if (argc) /* started from CLI */
  448.     {   if (!(ArgsPtr = ReadArgs
  449.         (   "-F=FILL/S,PUBSCREEN/K,FUNCTION/N,ICONTYPE/K,"
  450.             "RESET/S,TIMEOUT/S,LUNS/S,SYNC_XFER/S,SLOW_SYNC/S,TAG_QUEUES/S,HOST_ID/K/N,"
  451.             "FILE/F",
  452.             (LONG *) args,
  453.             NULL
  454.     )))
  455.         {   Printf
  456.             (   "Usage: %s [-f=FILL] [PUBSCREEN <screen>]"
  457.                 "[[FUNCTION] <function> "
  458.                 "[ICONTYPE DISK|DRAWER|TOOL|PROJECT|TRASHCAN|DEVICE|KICKSTART|APPICON] "
  459.                 "[RESET [TIMEOUT] [LUNS] [SYNC_XFER] [SLOW_SYNC] [TAG_QUEUES] [HOST_ID <host_id>]] "
  460.                 "[[FILE] <file(s)...>]]\n",
  461.                 argv[0]
  462.             );
  463.             cleanexit(EXIT_FAILURE);
  464.     }
  465.         if (args[0])
  466.         {   fillwindows = TRUE;
  467.         }
  468.         if (args[1])
  469.         {   strcpy(pubscreen, (STRPTR) args[1]);
  470.         }
  471.         if (args[2])
  472.         {   number = (SLONG) (*((SLONG *) args[2]));
  473.             if (number >= 1 && number <= FUNCTIONS)
  474.             {   page = closer = (number * 10) + 1;
  475.                 shared.function = number;
  476.             } else
  477.             {   Printf("Report+: <function> must be 1-%ld!\n", FUNCTIONS);
  478.                 cleanexit(EXIT_FAILURE);
  479.         }   }
  480.         if (args[3])
  481.         {   if (number != 12)
  482.             {   Printf("%s: <function> must be 12 for this!\n", argv[0]);
  483.                 cleanexit(EXIT_FAILURE);
  484.             }
  485.             if (!stricmp((STRPTR) args[3], "DISK"))
  486.             {   icon.type = WBDISK;
  487.             } elif (!stricmp((STRPTR) args[3], "DRAWER"))
  488.             {   icon.type = WBDRAWER;
  489.             } elif (!stricmp((STRPTR) args[3], "TOOL"))
  490.             {   icon.type = WBTOOL;
  491.             } elif (!stricmp((STRPTR) args[3], "PROJECT"))
  492.             {   icon.type = WBPROJECT;
  493.             } elif (!stricmp((STRPTR) args[3], "TRASHCAN"))
  494.             {   icon.type = WBGARBAGE;
  495.             } elif (!stricmp((STRPTR) args[3], "DEVICE"))
  496.             {   icon.type = WBDEVICE;
  497.             } elif (!stricmp((STRPTR) args[3], "KICKSTART"))
  498.             {   icon.type = WBKICK;
  499.             } elif (!stricmp((STRPTR) args[3], "APPICON"))
  500.             {   icon.type = WBAPPICON;
  501.             } else
  502.             {   Printf("%s: <icontype> must be DISK, DRAWER, TOOL, PROJECT, TRASHCAN, DEVICE, KICKSTART or APPICON!\n", argv[0]);
  503.                 cleanexit(EXIT_FAILURE);
  504.         }   }
  505.         if (args[4] || args[5] || args[6] || args[7] || args[8] || args[9] || args[10])
  506.         {   if (number != 9)
  507.             {   Printf("%s: <function> must be 9 for this!\n", argv[0]);
  508.                 cleanexit(EXIT_FAILURE);
  509.             }
  510.             if (!args[4])
  511.             {   Printf("%s: You need the RESET switch for this!\n", argv[0]);
  512.                 cleanexit(EXIT_FAILURE);
  513.             }
  514.             for (i = 0; i <= 95; i++)
  515.             {   BattBuffer[i] = FALSE;
  516.             }
  517.             BattBuffer[BATTMEM_AMIGA_AMNESIA_ADDR]          =
  518.             BattBuffer[BATTMEM_SHARED_AMNESIA_ADDR]         = TRUE; // these bits are inverted
  519.             if (args[5])
  520.             {   BattBuffer[BATTMEM_SCSI_TIMEOUT_ADDR]       = TRUE;
  521.             } else BattBuffer[BATTMEM_SCSI_TIMEOUT_ADDR]    = FALSE;
  522.             if (args[6])
  523.             {   BattBuffer[BATTMEM_SCSI_LUNS_ADDR]          = TRUE;
  524.             } else BattBuffer[BATTMEM_SCSI_LUNS_ADDR]       = FALSE;
  525.             if (args[7])
  526.             {   BattBuffer[BATTMEM_SCSI_SYNC_XFER_ADDR]     = TRUE;
  527.             } else BattBuffer[BATTMEM_SCSI_SYNC_XFER_ADDR]  = FALSE;
  528.             if (args[8])
  529.             {   BattBuffer[BATTMEM_SCSI_FAST_SYNC_ADDR]     = TRUE;
  530.             } else BattBuffer[BATTMEM_SCSI_FAST_SYNC_ADDR]  = FALSE;
  531.             if (args[9])
  532.             {   BattBuffer[BATTMEM_SCSI_TAG_QUEUES_ADDR]    = TRUE;
  533.             } else BattBuffer[BATTMEM_SCSI_TAG_QUEUES_ADDR] = FALSE;
  534.             if (args[10]) // these bits are inverted
  535.             {   hostid = (SLONG) (*((SLONG *) args[9]));
  536.                 if (hostid < 0 || hostid > 7)
  537.                 {   Printf("%s: <host_id> must be 0-7!\n", argv[0]);
  538.                     cleanexit(EXIT_FAILURE);
  539.                 }
  540.                 BattBuffer[BATTMEM_SCSI_HOST_ID_ADDR]     = (hostid & 4)? 0 : 1;
  541.                 BattBuffer[BATTMEM_SCSI_HOST_ID_ADDR + 1] = (hostid & 2)? 0 : 1;
  542.                 BattBuffer[BATTMEM_SCSI_HOST_ID_ADDR + 2] = (hostid & 1)? 0 : 1;
  543.             }
  544.             if (!BattMemBase)
  545.             {   if (!(BattMemBase = OpenResource(BATTMEMNAME)))
  546.                 {   rq("Can't open battery RAM resource!");
  547.             }   }
  548.             writebatt(FALSE);
  549.             Printf("Done.\n");
  550.             cleanexit(EXIT_SUCCESS);
  551.         }
  552.         if (args[11])
  553.         {   switch(number)
  554.             {
  555.             case 1:
  556.                 strcpy(report.output, (STRPTR) args[11]);
  557.                 report.loaded = TRUE;
  558.                 loadreport();
  559.             break;
  560.             case 2:
  561.                 strcpy(aminet.output, (STRPTR) args[11]);
  562.                 aminet.loaded = TRUE;
  563.                 loadaminet();
  564.             break;
  565.             case 6:
  566.                 strcpy(iff.pathname, (STRPTR) args[11]);
  567.             break;
  568.             case 7:
  569.                 strcpy(shared.pathname, (STRPTR) args[11]);
  570.                 convert(FALSE);
  571.                 Printf("All done.\n");
  572.                 cleanexit(EXIT_SUCCESS);
  573.             break;
  574.             case 11:
  575.                 strcpy(  agdb.output, (STRPTR) args[11]);
  576.                 agdb.loaded = TRUE;
  577.                 loadagdb();
  578.             break;
  579.             case 12:
  580.                 strcpy(shared.pathname, (STRPTR) args[11]);
  581.                 convert(FALSE);
  582.                 Printf("All done.\n");
  583.                 cleanexit(EXIT_SUCCESS);
  584.             break;
  585.             default:
  586.                 Printf("Report+: <function> must be 1, 2, 6, 7, 11 or 12 for this!\n");
  587.                 cleanexit(EXIT_FAILURE);
  588.             break;
  589.     }   }   }
  590.     else /* started from WB */
  591.     {   WBMsg = (struct WBStartup *) argv;
  592.         WBArg = WBMsg->sm_ArgList; /* head of the arg list */
  593.         for (i = 0; i < WBMsg->sm_NumArgs; i++, WBArg++)
  594.         {   if (WBArg->wa_Lock)
  595.             {   /* something that does not support locks */
  596.                 parsewb();
  597.             } else
  598.             {   /* lock supported; change to the proper directory */
  599.                 OldDir = CurrentDir(WBArg->wa_Lock);
  600.                 parsewb();
  601.                 CurrentDir(OldDir);
  602.             }
  603.             if (i == 1)
  604.             {   ; /* we were started from a project icon, which is
  605.                 currently unsupported */
  606.     }   }   }
  607.  
  608.     strcpy(asldir, "PROGDIR:");
  609.     /* RKM Libraries, p. 59-61: */
  610.     lockscreen();
  611.     if (GetVPModeID(&(ScreenPtr->ViewPort)) == INVALID_ID)
  612.     {   rq("Invalid default public screen mode ID!");
  613.     }
  614.     xsize = ScreenPtr->Width;
  615.     ysize = ScreenPtr->Height;
  616.     unlockscreen();
  617.  
  618.     for (i = 0; i <= FUNCTIONS; i++)
  619.     {   windowx[i] = windowy[i] = -1;
  620.     }
  621.  
  622.     if (ConfigHandle = (BPTR) Open("PROGDIR:ReportPlus.config", MODE_OLDFILE))
  623.     {   if (Read(ConfigHandle, IOBuffer, 19) != -1)
  624.         {   shared.log = IOBuffer[0];
  625.             eol_config();
  626.             size_config();
  627.             files_config();
  628.             icon_config();
  629.         }
  630.         Close(ConfigHandle);
  631.         ConfigHandle = NULL;
  632.     }
  633.  
  634.     while(1)
  635.     {   shared.function = page / 10;
  636.         if (page == 11)
  637.             report1();
  638.         elif (page == 12)
  639.             sender();
  640.         elif (page == 13)
  641.             config();
  642.         elif (page == 21)
  643.             aminet1();
  644.         elif (page == 31)
  645.             acse1();
  646.         elif (page == 32)
  647.             acse2();
  648.         elif (page == 33)
  649.             acse3();
  650.         elif (page == 41)
  651.             autodoc1();
  652.         elif (page == 51)
  653.             manuf1();
  654.         elif (page == 61)
  655.             iff1();
  656.         elif (page == 71)
  657.             eol1();
  658.         elif (page == 81)
  659.             size1();
  660.         elif (page == 91)
  661.             batt1();
  662.         elif (page == 101)
  663.             files1();
  664.         elif (page == 111)
  665.             agdb1();
  666.         elif (page == 121)
  667.         {   icon1();
  668.         } else
  669.         {   /* assert(page == 0); */
  670.             menu();
  671. }   }   }
  672.  
  673. MODULE void menu(void)
  674. {   /* PAGE 0 ************************************************************* */
  675.  
  676.     struct Hook Hook0Struct;
  677.  
  678.     certified = FALSE;
  679.  
  680.     gadtools(); // needed for menu strip
  681.     InitHook(&Hook0Struct, Hook0Func, NULL);
  682.  
  683.     lockscreen();
  684.     if (!(Window0Object = NewObject(WINDOW_GetClass(), NULL,
  685.         // window tags
  686.         WA_PubScreen,             ScreenPtr,
  687.         WA_ScreenTitle,           TITLEBARTEXT,
  688.         WA_Title,                 "Report+: Main Menu",
  689.         WA_Activate,              TRUE,
  690.         WA_DepthGadget,           TRUE,
  691.         WA_DragBar,               TRUE,
  692.         WA_CloseGadget,           TRUE,
  693.         WA_IDCMP,                 IDCMP_RAWKEY | IDCMP_INTUITICKS,
  694.         WINDOW_IDCMPHook,         &Hook0Struct,
  695.         WINDOW_IDCMPHookBits,     IDCMP_RAWKEY | IDCMP_INTUITICKS,
  696.         WINDOW_MenuStrip,         MenuPtr,
  697.         WINDOW_Position,          WPOS_CENTERSCREEN,
  698.         WINDOW_ParentGroup,       gadgets[GID_0_LY1] =
  699.         NewObject
  700.         (   LAYOUT_GetClass(),         NULL,
  701.             // root-layout tags
  702.             LAYOUT_Orientation,        LAYOUT_ORIENT_VERT,
  703.             LAYOUT_SpaceOuter,         TRUE,
  704.             LAYOUT_DeferLayout,        TRUE,
  705.             LAYOUT_AddChild,
  706.             NewObject
  707.             (   LAYOUT_GetClass(),     NULL,
  708.                 // layout tags
  709.                 LAYOUT_Orientation,    LAYOUT_ORIENT_HORIZ,
  710.                 LAYOUT_SpaceOuter,     TRUE,
  711.                 LAYOUT_DeferLayout,    TRUE,
  712.                 LAYOUT_HorizAlignment, LALIGN_CENTER,
  713.                 LAYOUT_AddImage,
  714.                 NewObject
  715.                 (   BITMAP_GetClass(), NULL,
  716.                     // bitmap tags
  717.                     BITMAP_SourceFile, "PROGDIR:images/logo.ilbm",
  718.                     BITMAP_Masking,    TRUE,
  719.                     BITMAP_Screen,     ScreenPtr,
  720.                     TAG_DONE
  721.                 ),
  722.                 TAG_DONE
  723.             ),
  724.             LAYOUT_AddChild,
  725.             NewObject
  726.             (   LAYOUT_GetClass(), NULL,
  727.                 // layout tags
  728.                 LAYOUT_Orientation,    LAYOUT_ORIENT_HORIZ,
  729.                 LAYOUT_SpaceOuter,     TRUE,
  730.                 LAYOUT_DeferLayout,    TRUE,
  731.                 LAYOUT_HorizAlignment, LALIGN_CENTER,
  732.                 LAYOUT_AddImage,
  733.                 NewObject
  734.                 (   LABEL_GetClass(),    NULL,
  735.                     // label tags
  736.                     LABEL_Justification, LJ_CENTRE,
  737.                     LABEL_Text,          "Edit:",
  738.                     TAG_END
  739.                 ),
  740.                 TAG_END
  741.             ),
  742.             CHILD_WeightedHeight,      0,
  743.             LAYOUT_AddChild,
  744.             NewObject
  745.             (   LAYOUT_GetClass(),         NULL,
  746.                 // layout tags
  747.                 LAYOUT_Orientation,        LAYOUT_ORIENT_HORIZ,
  748.                 LAYOUT_SpaceOuter,         TRUE,
  749.                 LAYOUT_DeferLayout,        TRUE,
  750.                 LAYOUT_AddChild,           gadgets[GID_0_BU1] =
  751.                 NewObject
  752.                 (   NULL, "button.gadget",
  753.                     // button tags
  754.                     GA_ID,                 GID_0_BU1,
  755.                     GA_Left,               20,
  756.                     GA_Top,                20,
  757.                     GA_Width,              41,
  758.                     GA_Height,             40,
  759.                     GA_RelVerify,          TRUE,
  760.                     GA_Image,
  761.                     NewObject
  762.                     (   BITMAP_GetClass(), NULL,
  763.                         // bitmap tags
  764.                         BITMAP_SourceFile, "PROGDIR:images/f1.ilbm",
  765.                         BITMAP_Screen,     ScreenPtr,
  766.                         TAG_DONE
  767.                     ),
  768.                     TAG_DONE
  769.                 ),
  770.                 LAYOUT_AddChild,           gadgets[GID_0_BU2] =
  771.                 NewObject
  772.                 (   NULL, "button.gadget",
  773.                     // button tags
  774.                     GA_ID,                 GID_0_BU2,
  775.                     GA_Left,               20,
  776.                     GA_Top,                20,
  777.                     GA_Width,              41,
  778.                     GA_Height,             40,
  779.                     GA_RelVerify,          TRUE,
  780.                     GA_Image,              NewObject
  781.                     (   BITMAP_GetClass(), NULL,
  782.                         // bitmap tags
  783.                         BITMAP_SourceFile, "PROGDIR:images/f2.ilbm",
  784.                         BITMAP_Screen,     ScreenPtr,
  785.                         TAG_DONE
  786.                     ),
  787.                     TAG_DONE
  788.                 ),
  789.                 LAYOUT_AddChild,           gadgets[GID_0_BU3] =
  790.                 NewObject
  791.                 (   NULL, "button.gadget",
  792.                     // button tags
  793.                     GA_ID,                 GID_0_BU3,
  794.                     GA_Left,               20,
  795.                     GA_Top,                20,
  796.                     GA_Width,              41,
  797.                     GA_Height,             40,
  798.                     GA_RelVerify,          TRUE,
  799.                     GA_Image,              NewObject
  800.                     (   BITMAP_GetClass(), NULL,
  801.                         // bitmap tags
  802.                         BITMAP_SourceFile, "PROGDIR:images/f4.ilbm",
  803.                         BITMAP_Screen,     ScreenPtr,
  804.                         TAG_DONE
  805.                     ),
  806.                     TAG_DONE
  807.                 ),
  808.                 LAYOUT_AddChild,           gadgets[GID_0_BU4] = NewObject
  809.                 (   NULL, "button.gadget",
  810.                     // button tags
  811.                     GA_ID,                 GID_0_BU4,
  812.                     GA_Left,               20,
  813.                     GA_Top,                20,
  814.                     GA_Width,              41,
  815.                     GA_Height,             40,
  816.                     GA_RelVerify,          TRUE,
  817.                     GA_Image,              NewObject
  818.                     (   BITMAP_GetClass(), NULL,
  819.                         // bitmap tags
  820.                         BITMAP_SourceFile, "PROGDIR:images/f9.ilbm",
  821.                         BITMAP_Screen,     ScreenPtr,
  822.                         TAG_DONE
  823.                     ),
  824.                     TAG_DONE
  825.                 ),
  826.                 LAYOUT_AddChild,           gadgets[GID_0_BU5] = (struct Gadget *) NewObject
  827.                 (   NULL, "button.gadget",
  828.                     // button tags
  829.                     GA_ID,                 GID_0_BU5,
  830.                     GA_Left,               20,
  831.                     GA_Top,                20,
  832.                     GA_Width,              41,
  833.                     GA_Height,             40,
  834.                     GA_RelVerify,          TRUE,
  835.                     GA_Image,              NewObject
  836.                     (   BITMAP_GetClass(), NULL,
  837.                         // bitmap tags
  838.                         BITMAP_SourceFile, "PROGDIR:images/f11.ilbm",
  839.                         BITMAP_Screen,     ScreenPtr,
  840.                         TAG_DONE
  841.                     ),
  842.                     TAG_DONE
  843.                 ),
  844.                 TAG_DONE
  845.             ),
  846.             LAYOUT_AddChild,
  847.             NewObject
  848.             (   LAYOUT_GetClass(),         NULL,
  849.                 // layout tags
  850.                 LAYOUT_Orientation,        LAYOUT_ORIENT_HORIZ,
  851.                 LAYOUT_SpaceOuter,         TRUE,
  852.                 LAYOUT_DeferLayout,        TRUE,
  853.                 LAYOUT_AddChild,
  854.                 NewObject
  855.                 (   LAYOUT_GetClass(),         NULL,
  856.                     // layout tags
  857.                     LAYOUT_Orientation,        LAYOUT_ORIENT_VERT,
  858.                     LAYOUT_SpaceOuter,         TRUE,
  859.                     LAYOUT_DeferLayout,        TRUE,
  860.                     LAYOUT_AddChild,
  861.                     NewObject
  862.                     (    LAYOUT_GetClass(),    NULL,
  863.                          // layout tags
  864.                          LAYOUT_Orientation,   LAYOUT_ORIENT_HORIZ,
  865.                          LAYOUT_SpaceOuter,    TRUE,
  866.                          LAYOUT_DeferLayout,   TRUE,
  867.                          LAYOUT_HorizAlignment, LALIGN_CENTER,
  868.                          LAYOUT_AddImage,
  869.                          NewObject
  870.                          (   LABEL_GetClass(), NULL,
  871.                              // label tags
  872.                              LABEL_Justification, LJ_CENTRE,
  873.                              LABEL_Text,          "View:",
  874.                              TAG_END
  875.                          ),
  876.                          TAG_DONE
  877.                     ),
  878.                     LAYOUT_AddChild,
  879.                     NewObject
  880.                     (   LAYOUT_GetClass(),         NULL,
  881.                         // layout tags
  882.                         LAYOUT_Orientation,        LAYOUT_ORIENT_HORIZ,
  883.                         LAYOUT_SpaceOuter,         TRUE,
  884.                         LAYOUT_DeferLayout,        TRUE,
  885.                         LAYOUT_AddChild,           gadgets[GID_0_BU6] =
  886.                         NewObject
  887.                         (   NULL, "button.gadget",
  888.                             // button tags
  889.                             GA_ID,                 GID_0_BU6,
  890.                             GA_Left,               20,
  891.                             GA_Top,                20,
  892.                             GA_Width,              41,
  893.                             GA_Height,             40,
  894.                             GA_RelVerify,          TRUE,
  895.                             GA_Image,              NewObject
  896.                             (   BITMAP_GetClass(), NULL,
  897.                                 // bitmap tags
  898.                                 BITMAP_SourceFile, "PROGDIR:images/f5.ilbm",
  899.                                 BITMAP_Screen,     ScreenPtr,
  900.                                 TAG_DONE
  901.                             ),
  902.                             TAG_DONE
  903.                         ),
  904.                         LAYOUT_AddChild,           gadgets[GID_0_BU7] =
  905.                         NewObject
  906.                         (   NULL, "button.gadget",
  907.                             // button tags
  908.                             GA_ID,                 GID_0_BU7,
  909.                             GA_Left,               20,
  910.                             GA_Top,                20,
  911.                             GA_Width,              41,
  912.                             GA_Height,             40,
  913.                             GA_RelVerify,          TRUE,
  914.                             GA_Image,              NewObject
  915.                             (   BITMAP_GetClass(), NULL,
  916.                                 // bitmap tags
  917.                                 BITMAP_SourceFile, "PROGDIR:images/f6.ilbm",
  918.                                 BITMAP_Screen,     ScreenPtr,
  919.                                 TAG_DONE
  920.                             ),
  921.                             TAG_DONE
  922.                         ),
  923.                         TAG_DONE
  924.                     ),
  925.                     TAG_DONE
  926.                 ),
  927.                 LAYOUT_AddChild,
  928.                 NewObject
  929.                 (   LAYOUT_GetClass(),         NULL,
  930.                     // layout tags
  931.                     LAYOUT_Orientation,        LAYOUT_ORIENT_VERT,
  932.                     LAYOUT_SpaceOuter,         TRUE,
  933.                     LAYOUT_DeferLayout,        TRUE,
  934.                     LAYOUT_AddChild,
  935.                     NewObject
  936.                     (    LAYOUT_GetClass(),    NULL,
  937.                          // layout tags
  938.                          LAYOUT_Orientation,   LAYOUT_ORIENT_HORIZ,
  939.                          LAYOUT_SpaceOuter,    TRUE,
  940.                          LAYOUT_DeferLayout,   TRUE,
  941.                          LAYOUT_HorizAlignment, LALIGN_CENTER,
  942.                          LAYOUT_AddImage,
  943.                          NewObject
  944.                          (   LABEL_GetClass(), NULL,
  945.                              // label tags
  946.                              LABEL_Justification, LJ_CENTRE,
  947.                              LABEL_Text,          "Process:",
  948.                              TAG_END
  949.                          ),
  950.                          TAG_DONE
  951.                     ),
  952.                     LAYOUT_AddChild,
  953.                     NewObject
  954.                     (   LAYOUT_GetClass(),         NULL,
  955.                         // layout tags
  956.                         LAYOUT_Orientation,        LAYOUT_ORIENT_HORIZ,
  957.                         LAYOUT_SpaceOuter,         TRUE,
  958.                         LAYOUT_DeferLayout,        TRUE,
  959.                         LAYOUT_AddChild,           gadgets[GID_0_BU8] =
  960.                         NewObject
  961.                         (   NULL, "button.gadget",
  962.                             // button tags
  963.                             GA_ID,                 GID_0_BU8,
  964.                             GA_Left,               20,
  965.                             GA_Top,                20,
  966.                             GA_Width,              41,
  967.                             GA_Height,             40,
  968.                             GA_RelVerify,          TRUE,
  969.                             GA_Image,              NewObject
  970.                             (   BITMAP_GetClass(), NULL,
  971.                                 // bitmap tags
  972.                                 BITMAP_SourceFile, "PROGDIR:images/f7.ilbm",
  973.                                 BITMAP_Screen,     ScreenPtr,
  974.                                 TAG_DONE
  975.                             ),
  976.                             TAG_DONE
  977.                         ),
  978.                         LAYOUT_AddChild,           gadgets[GID_0_BU9] =
  979.                         NewObject
  980.                         (   NULL, "button.gadget",
  981.                             // button tags
  982.                             GA_ID,                 GID_0_BU9,
  983.                             GA_Left,               20,
  984.                             GA_Top,                20,
  985.                             GA_Width,              41,
  986.                             GA_Height,             40,
  987.                             GA_RelVerify,          TRUE,
  988.                             GA_Image,              NewObject
  989.                             (   BITMAP_GetClass(), NULL,
  990.                                 // bitmap tags
  991.                                 BITMAP_SourceFile, "PROGDIR:images/f12.ilbm",
  992.                                 BITMAP_Screen,     ScreenPtr,
  993.                                 TAG_DONE
  994.                             ),
  995.                             TAG_DONE
  996.                         ),
  997.                         TAG_DONE
  998.                     ),
  999.                     TAG_DONE
  1000.                 ),
  1001.                 TAG_DONE
  1002.             ),
  1003.             LAYOUT_AddChild,
  1004.             NewObject
  1005.             (   LAYOUT_GetClass(),         NULL,
  1006.                 // layout tags
  1007.                 LAYOUT_Orientation,        LAYOUT_ORIENT_HORIZ,
  1008.                 LAYOUT_SpaceOuter,         TRUE,
  1009.                 LAYOUT_DeferLayout,        TRUE,
  1010.                 LAYOUT_AddChild,
  1011.                 NewObject
  1012.                 (   LAYOUT_GetClass(),         NULL,
  1013.                     // layout tags
  1014.                     LAYOUT_Orientation,        LAYOUT_ORIENT_VERT,
  1015.                     LAYOUT_SpaceOuter,         TRUE,
  1016.                     LAYOUT_DeferLayout,        TRUE,
  1017.                     LAYOUT_AddChild,
  1018.                     NewObject
  1019.                     (    LAYOUT_GetClass(),       NULL,
  1020.                          // layout tags
  1021.                          LAYOUT_Orientation,      LAYOUT_ORIENT_HORIZ,
  1022.                          LAYOUT_SpaceOuter,       TRUE,
  1023.                          LAYOUT_DeferLayout,      TRUE,
  1024.                          LAYOUT_HorizAlignment,   LALIGN_CENTER,
  1025.                          LAYOUT_AddImage,
  1026.                          NewObject
  1027.                          (   LABEL_GetClass(),    NULL,
  1028.                              // label tags
  1029.                              LABEL_Justification, LJ_CENTRE,
  1030.                              LABEL_Text,          "Report:",
  1031.                              TAG_END
  1032.                          ),
  1033.                          TAG_DONE
  1034.                     ),
  1035.                     LAYOUT_AddChild,
  1036.                     NewObject
  1037.                     (   LAYOUT_GetClass(),         NULL,
  1038.                         // layout tags
  1039.                         LAYOUT_Orientation,        LAYOUT_ORIENT_HORIZ,
  1040.                         LAYOUT_SpaceOuter,         TRUE,
  1041.                         LAYOUT_DeferLayout,        TRUE,
  1042.                         LAYOUT_AddChild,           gadgets[GID_0_BU10] =
  1043.                         NewObject
  1044.                         (   NULL, "button.gadget",
  1045.                             // button tags
  1046.                             GA_ID,                 GID_0_BU10,
  1047.                             GA_Left,               20,
  1048.                             GA_Top,                20,
  1049.                             GA_Width,              41,
  1050.                             GA_Height,             40,
  1051.                             GA_RelVerify,          TRUE,
  1052.                             GA_Image,              NewObject
  1053.                             (   BITMAP_GetClass(), NULL,
  1054.                                 // bitmap tags
  1055.                                 BITMAP_SourceFile, "PROGDIR:images/f8.ilbm",
  1056.                                 BITMAP_Screen,     ScreenPtr,
  1057.                                 TAG_DONE
  1058.                             ),
  1059.                             TAG_DONE
  1060.                         ),
  1061.                         LAYOUT_AddChild,           gadgets[GID_0_BU11] =
  1062.                         NewObject
  1063.                         (   NULL,                  "button.gadget",
  1064.                             // button tags
  1065.                             GA_ID,                 GID_0_BU11,
  1066.                             GA_Left,               20,
  1067.                             GA_Top,                20,
  1068.                             GA_Width,              41,
  1069.                             GA_Height,             40,
  1070.                             GA_RelVerify,          TRUE,
  1071.                             GA_Image,              NewObject
  1072.                             (   BITMAP_GetClass(), NULL,
  1073.                                 // bitmap tags
  1074.                                 BITMAP_SourceFile, "PROGDIR:images/f10.ilbm",
  1075.                                 BITMAP_Screen,     ScreenPtr,
  1076.                                 TAG_DONE
  1077.                             ),
  1078.                             TAG_DONE
  1079.                         ),
  1080.                         TAG_DONE
  1081.                     ),
  1082.                     TAG_DONE
  1083.                 ),
  1084.                 LAYOUT_AddChild,
  1085.                 NewObject
  1086.                 (   LAYOUT_GetClass(),         NULL,
  1087.                     // layout tags
  1088.                     LAYOUT_Orientation,        LAYOUT_ORIENT_VERT,
  1089.                     LAYOUT_SpaceOuter,         TRUE,
  1090.                     LAYOUT_DeferLayout,        TRUE,
  1091.                     LAYOUT_AddChild,
  1092.                     NewObject
  1093.                     (    LAYOUT_GetClass(),    NULL,
  1094.                          // layout tags
  1095.                          LAYOUT_Orientation,   LAYOUT_ORIENT_HORIZ,
  1096.                          LAYOUT_SpaceOuter,    TRUE,
  1097.                          LAYOUT_DeferLayout,   TRUE,
  1098.                          LAYOUT_HorizAlignment, LALIGN_CENTER,
  1099.                          LAYOUT_AddImage,
  1100.                          NewObject
  1101.                          (   LABEL_GetClass(), NULL,
  1102.                              // label tags
  1103.                              LABEL_Justification, LJ_CENTRE,
  1104.                              LABEL_Text,          "Conduct:",
  1105.                              TAG_END
  1106.                          ),
  1107.                          TAG_DONE
  1108.                     ),
  1109.                     LAYOUT_AddChild,
  1110.                     NewObject
  1111.                     (   LAYOUT_GetClass(),         NULL,
  1112.                         // layout tags
  1113.                         LAYOUT_Orientation,        LAYOUT_ORIENT_HORIZ,
  1114.                         LAYOUT_SpaceOuter,         TRUE,
  1115.                         LAYOUT_DeferLayout,        TRUE,
  1116.                         LAYOUT_AddChild,           gadgets[GID_0_BU12] =
  1117.                         NewObject
  1118.                         (   NULL, "button.gadget",
  1119.                             // button tags
  1120.                             GA_ID,                 GID_0_BU12,
  1121.                             GA_Left,               20,
  1122.                             GA_Top,                20,
  1123.                             GA_Width,              41,
  1124.                             GA_Height,             40,
  1125.                             GA_RelVerify,          TRUE,
  1126.                             GA_Image,              NewObject
  1127.                             (   BITMAP_GetClass(), NULL,
  1128.                                 // bitmap tags
  1129.                                 BITMAP_SourceFile, "PROGDIR:images/f3.ilbm",
  1130.                                 BITMAP_Screen,     ScreenPtr,
  1131.                                 TAG_DONE
  1132.                             ),
  1133.                             TAG_DONE
  1134.                         ),
  1135.                         TAG_DONE
  1136.                     ),
  1137.                     TAG_DONE
  1138.                 ),
  1139.                 TAG_DONE
  1140.             ),
  1141.             LAYOUT_AddChild,          gadgets[GID_0_ST1] =
  1142.             NewObject
  1143.             (   STRING_GetClass(),    NULL,
  1144.                 // string tags
  1145.                 GA_ID,                GID_0_ST1,
  1146.                 GA_ReadOnly,          TRUE,
  1147.                 STRINGA_TextVal,      TITLEBARTEXT,
  1148.                 TAG_END
  1149.             ),
  1150.             CHILD_WeightedHeight,     0,
  1151.             TAG_DONE
  1152.         ),
  1153.         TAG_DONE
  1154.     )))
  1155.     {   rq("Can't create ReAction gadgets!");
  1156.     }
  1157.     unlockscreen();
  1158.  
  1159.     if (!(MainWindowPtr = (struct Window *) DoMethod((Object *) Window0Object, WM_OPEN, NULL)))
  1160.     {   rq("Can't open ReAction window!");
  1161.     }
  1162.     // Obtain the window wait signal mask.
  1163.     GetAttr(WINDOW_SigMask, Window0Object, &signal);
  1164.  
  1165.     loop();
  1166.     closewindow();
  1167. }
  1168.  
  1169. AGLOBAL void cleanexit(SBYTE rc)
  1170. {   BPTR ConfigHandle;
  1171.  
  1172.     /* ASL requesters are assumed to be already closed.
  1173.     iffparse.library is never opened or closed. :-O */
  1174.  
  1175.     /* help|about... */
  1176.     if (AboutWindowPtr)
  1177.     {   CloseWindow(AboutWindowPtr);
  1178.         AboutWindowPtr = NULL;
  1179.     }
  1180.  
  1181.     /* all */
  1182.     unlockscreen(); // in case the screen is locked
  1183.     closewindow();
  1184.  
  1185.     IOBuffer[0] = shared.log;
  1186.  
  1187.     /* Remember that you can't fool around with the list whilst the
  1188.     gadget is still using it. So we close the window before calling
  1189.     these next routines. */
  1190.  
  1191.     report_die();  // f1: deallocates "subsystem" list
  1192.     aminet_exit(); // f2: deallocates "subdirectory" list
  1193.     aminet_die();  // f2: deallocates "main directory" list
  1194.     acse_exit();   // f3: shuts down timer
  1195.     eol_die();
  1196.     size_exit();
  1197.     size_die();    // f8: deallocates "empty" (1-node) columnar list
  1198.     files_exit();  // f10: deallocates "result" list & closes logfile handle
  1199.     files_die();
  1200.     icon_die();
  1201.  
  1202.     if (EADataPtr)
  1203.     {   FreeVec(EADataPtr);
  1204.         EADataPtr = NULL;
  1205.     }
  1206.     if (FontPtr)
  1207.     {   CloseFont(FontPtr);
  1208.         FontPtr = NULL;
  1209.     }
  1210.     if (ArgsPtr)
  1211.     {   FreeArgs(ArgsPtr);
  1212.         ArgsPtr = NULL;
  1213.     }
  1214.  
  1215.     /* Reaction */
  1216.     CloseLibrary(ButtonBase);
  1217.     CloseLibrary(CheckBoxBase);
  1218.     CloseLibrary(ChooserBase);
  1219.     CloseLibrary(LabelBase);
  1220.     CloseLibrary(LayoutBase);
  1221.     CloseLibrary(StringBase);
  1222.     CloseLibrary(TextEditorBase);
  1223.     CloseLibrary(BitMapBase);
  1224.     CloseLibrary(ListBrowserBase);
  1225.     CloseLibrary(WindowBase);
  1226.  
  1227.     if (BoardsBase)
  1228.         CloseLibrary((struct Library *) BoardsBase);
  1229.     if (IconBase)
  1230.         CloseLibrary((struct Library *) IconBase);
  1231.     if (DiskFontBase)
  1232.         CloseLibrary((struct Library *) DiskFontBase);
  1233.     if (ASLBase)
  1234.         CloseLibrary((struct Library *) ASLBase);
  1235.     if (GadToolsBase)
  1236.         CloseLibrary((struct Library *) GadToolsBase);
  1237.     if (IntuitionBase)
  1238.     {   OpenWorkBench();
  1239.         CloseLibrary((struct Library *) IntuitionBase);
  1240.     }
  1241.  
  1242.     if (rc == EXIT_SUCCESS)
  1243.     {   if (ConfigHandle = (BPTR) Open("PROGDIR:ReportPlus.config", MODE_NEWFILE))
  1244.         {   Write(ConfigHandle, IOBuffer, 19);
  1245.             Close(ConfigHandle);
  1246.             ConfigHandle = NULL;
  1247.     }   }
  1248.  
  1249.     exit(rc); /* End of program. */
  1250. }
  1251.  
  1252. MODULE void clearkybd(void)
  1253. {   struct IntuiMessage* MsgPtr;
  1254.  
  1255.     while (MsgPtr = (struct IntuiMessage *) GT_GetIMsg(MainWindowPtr->UserPort))
  1256.         GT_ReplyIMsg(MsgPtr);
  1257. }
  1258.  
  1259. AGLOBAL void FreeNameNodes(struct List* ListPtr)
  1260. {   /* RKM Libraries, p. 496:
  1261.     
  1262.     "Free the entire list, including the header. The header is not
  1263.     updated as the list is freed. This function demonstrates how to
  1264.     avoid referencing freed memory when deallocating nodes." */
  1265.  
  1266.     struct NameNode *WorkNodePtr, *NextNodePtr;
  1267.     
  1268.     WorkNodePtr = (struct NameNode *) (ListPtr->lh_Head); /* first node */
  1269.     while (NextNodePtr = (struct NameNode *) (WorkNodePtr->nn_Node.ln_Succ))
  1270.     {   FreeMem(WorkNodePtr, sizeof(struct NameNode));
  1271.         WorkNodePtr = NextNodePtr;
  1272. }   }
  1273.  
  1274. AGLOBAL void gadtools(void)
  1275. {   lockscreen();
  1276.     if (!(Gadget.ng_VisualInfo = VisualInfoPtr = (struct VisualInfo *) GetVisualInfo(ScreenPtr, TAG_DONE)))
  1277.     {   rq("Can't get GadTools visual info!");
  1278.     }
  1279.     unlockscreen();
  1280.  
  1281.     if (!(MenuPtr = (struct Menu *) CreateMenus(NewMenu, TAG_DONE)))
  1282.     {   rq("Can't create menus!");
  1283.     }
  1284.     if (!(LayoutMenus(MenuPtr, VisualInfoPtr, GTMN_NewLookMenus, TRUE, TAG_DONE)))
  1285.     {   rq("Can't lay out menus!");
  1286.     }
  1287.     GListPtr = NULL; /* that needs doing for the CreateContext() call */
  1288.     if (!(PrevGadPtr = (struct Gadget *) CreateContext(&GListPtr)))
  1289.     {   rq("Can't create GadTools context!");
  1290. }   }
  1291.  
  1292. AGLOBAL void verynewwindow(SWORD width, SWORD height, STRPTR title, ULONG idcmp)
  1293. {   WORD thewindowx, thewindowy;
  1294.  
  1295.     gadtools();
  1296.     lockscreen();
  1297.  
  1298.     if (page == 32 || page == 33)
  1299.     {   thewindowx = (xsize / 2) - (width / 2);
  1300.         thewindowy = 12 + ((ysize - 12) / 2) - (height / 2);
  1301.     } else
  1302.     {   if (windowx[page / 10] == -1)
  1303.         {   windowx[page / 10] = (xsize / 2) - (width / 2);
  1304.             windowy[page / 10] = 12 + ((ysize - 12) / 2) - (height / 2);
  1305.         }
  1306.         thewindowx = windowx[page / 10];
  1307.         thewindowy = windowy[page / 10];
  1308.     }
  1309.  
  1310.     /* open the window on the public screen */
  1311.     if (!(MainWindowPtr = (struct Window*) OpenWindowTags
  1312.     (   NULL,
  1313.         WA_Left,         thewindowx,
  1314.         WA_Top,          thewindowy,
  1315.         WA_Width,        width,
  1316.         WA_Height,       height,
  1317.         WA_IDCMP,        IDCMP_CLOSEWINDOW | IDCMP_MENUPICK | IDCMP_REFRESHWINDOW
  1318.                          | IDCMP_MOUSEBUTTONS | IDCMP_INTUITICKS | IDCMP_VANILLAKEY
  1319.                          | IDCMP_RAWKEY | idcmp,
  1320.         WA_Gadgets,      NULL,
  1321.         WA_PubScreen,    ScreenPtr,
  1322.         WA_Activate,     TRUE,
  1323.         WA_Title,        title,
  1324.         WA_DragBar,      TRUE,
  1325.         WA_DepthGadget,  TRUE,
  1326.         WA_CloseGadget,  TRUE,
  1327.         WA_SmartRefresh, TRUE,
  1328.         WA_NewLookMenus, TRUE,
  1329.         TAG_DONE
  1330.     )))
  1331.     {   rq("Can't open window!");
  1332.     }
  1333.     unlockscreen();
  1334.     signal = 1L << MainWindowPtr->UserPort->mp_SigBit;
  1335.  
  1336.     SetMenuStrip(MainWindowPtr, MenuPtr);
  1337.     SetFont(MainWindowPtr->RPort, FontPtr);
  1338.  
  1339.     if (fillwindows)
  1340.     {   getfillcolour();
  1341.         SetAPen
  1342.         (   MainWindowPtr->RPort,
  1343.             fillcolour
  1344.         );
  1345.         RectFill
  1346.         (   MainWindowPtr->RPort,
  1347.             MainWindowPtr->BorderLeft,
  1348.             MainWindowPtr->BorderTop,
  1349.              width - 1 - MainWindowPtr->BorderRight,
  1350.             height - 1 - MainWindowPtr->BorderBottom
  1351.         );
  1352.     }
  1353.  
  1354.     navigate();
  1355. }
  1356.  
  1357. AGLOBAL void helpabout(void)
  1358. {   SBYTE line;
  1359.     TEXT  ks[5], wb[5];
  1360.  
  1361.     OffMenu(MainWindowPtr, FULLMENUNUM(MN_HELP, IN_ABOUT, NOSUB));
  1362.     switch(ksval)
  1363.     {
  1364.     case 40:
  1365.         strcpy(ks, "3.1 ");
  1366.     break;
  1367.     default:
  1368.         strcpy(ks, "4.0+");
  1369.     break;
  1370.     }
  1371.     switch(wbval)
  1372.     {
  1373.     break;
  1374.     case 44:
  1375.         strcpy(wb, "3.5 ");
  1376.     break;
  1377.     case 45:
  1378.         strcpy(wb, "3.9 ");
  1379.     break;
  1380.     default:
  1381.         strcpy(wb, "4.0+");
  1382.     break;
  1383.     }
  1384.  
  1385.     lockscreen();
  1386.     if (!(AboutWindowPtr = (struct Window *) OpenWindowTags
  1387.     (   NULL,
  1388.         WA_Left,          (xsize / 2) - (ABOUTXPIXEL / 2),
  1389.         WA_Top,           12 + ((ysize - 12) / 2) - (ABOUTYPIXEL / 2),
  1390.         WA_Width,         ABOUTXPIXEL,
  1391.         WA_Height,        ABOUTYPIXEL,
  1392.         WA_IDCMP,         IDCMP_CLOSEWINDOW | IDCMP_RAWKEY,
  1393.         WA_Title,         "About Report+",
  1394.         WA_Gadgets,       NULL,
  1395.         WA_PubScreen,     ScreenPtr,
  1396.         WA_DragBar,       TRUE,
  1397.         WA_DepthGadget,   TRUE,
  1398.         WA_CloseGadget,   TRUE,
  1399.         WA_NoCareRefresh, TRUE,
  1400.         WA_Activate,      TRUE,
  1401.         TAG_DONE
  1402.     )))
  1403.     {   rq("Can't open About... window!");
  1404.     }
  1405.     unlockscreen();
  1406.  
  1407.     SetFont(AboutWindowPtr->RPort, FontPtr);
  1408.     SetDrMd(AboutWindowPtr->RPort, JAM1);
  1409.     SetAPen(AboutWindowPtr->RPort, BLACK);
  1410.     for (line = 0; line <= ABOUTLINES; line++)
  1411.     {   Move(AboutWindowPtr->RPort, about[line].x, about[line].y);
  1412.         Text(AboutWindowPtr->RPort, about[line].text, (SBYTE) strlen(about[line].text));
  1413.         if (line == 4)
  1414.         {   Text(AboutWindowPtr->RPort, ks, 4);
  1415.         } elif (line == 5)
  1416.         {   Text(AboutWindowPtr->RPort, wb, 4);
  1417.     }   }
  1418.  
  1419.     DrawBevelBox(AboutWindowPtr->RPort, 19, 21, 45, 46, GT_VisualInfo, VisualInfoPtr, GTBB_Recessed, TRUE, TAG_DONE);
  1420.     DrawImage(AboutWindowPtr->RPort, &PubAbout, 20, 22);
  1421. }
  1422.  
  1423. AGLOBAL void closewindow(void)
  1424. {   if (MainWindowPtr)
  1425.     {   clearkybd();
  1426.  
  1427.         if (closer != 32 && closer != 33)
  1428.         {    // memorize the position of the window, for next time
  1429.              windowx[closer / 10] = MainWindowPtr->LeftEdge;
  1430.              windowy[closer / 10] = MainWindowPtr->TopEdge;
  1431.         }
  1432.         if (closer == 0 || closer == 121)
  1433.         {   /* Disposing of the window object will also close the window if it is
  1434.              * already opened, and it will dispose of the layout object attached to it.
  1435.              */
  1436.             if (closer == 0)
  1437.             {   DisposeObject(Window0Object);
  1438.             } else
  1439.             {   assert(closer == 121);
  1440.                 DisposeObject(Window12Object);
  1441.             }
  1442.             MainWindowPtr = NULL;
  1443.         } else
  1444.         {   ClearMenuStrip(MainWindowPtr);
  1445.             CloseWindow(MainWindowPtr);
  1446.             MainWindowPtr = NULL;
  1447.     }   }
  1448.     if (GListPtr)
  1449.     {   FreeGadgets(GListPtr);
  1450.         GListPtr = NULL;
  1451.     }
  1452.     if (MenuPtr)
  1453.     {   FreeMenus(MenuPtr);
  1454.         MenuPtr = NULL;
  1455.     }
  1456.     if (VisualInfoPtr)
  1457.     {   FreeVisualInfo(VisualInfoPtr);
  1458.         VisualInfoPtr = NULL;
  1459. }   }
  1460.  
  1461. AGLOBAL ABOOL asl(void)
  1462. {   struct FileRequester* ASLRqPtr;
  1463.     ABOOL                 success;
  1464.  
  1465.     if (!(ASLRqPtr = AllocAslRequestTags(ASL_FileRequest, ASL_Pattern, "~(#?.info)", ASL_Window, MainWindowPtr, TAG_DONE)))
  1466.         rq("Can't create ASL request!");
  1467.     if
  1468.     (   AslRequestTags(ASLRqPtr, ASL_Dir, asldir, ASL_Hail, "Report+ file selector", ASL_FuncFlags, FILF_PATGAD, TAG_DONE)
  1469.      && *(ASLRqPtr->rf_File) != 0
  1470.     )
  1471.     {   strcpy(asldir, ASLRqPtr->rf_Dir);
  1472.         strcpy(aslresult, ASLRqPtr->rf_Dir);
  1473.         if (!AddPart(aslresult, ASLRqPtr->rf_File, VLONGFIELD))
  1474.             rq("Can't add filename to pathname!");
  1475.         success = TRUE;
  1476.     } else
  1477.     {   strcpy(asldir, "");
  1478.         strcpy(aslresult, "");
  1479.         success = FALSE;
  1480.     }
  1481.     FreeAslRequest(ASLRqPtr);
  1482.     return(success);
  1483. }
  1484.  
  1485. AGLOBAL void loop(void)
  1486. {   AUTO SWORD                oldpage = page;
  1487.     AUTO struct Gadget*       addr;
  1488.     AUTO struct IntuiMessage* MsgPtr;
  1489.     AUTO UWORD                code, qual;
  1490.     AUTO ULONG                class, signals, result;
  1491.     AUTO SWORD                mousex, mousey;
  1492.  
  1493.     closer = page;
  1494.     done = FALSE;
  1495.     while (page == oldpage && !done)
  1496.     {   if (AboutWindowPtr)
  1497.         {   signals = SetSignal(0L, 0L);
  1498.             if (signals & SIGBREAKF_CTRL_C)
  1499.             {   done = TRUE;
  1500.                 SetSignal(0L, SIGBREAKF_CTRL_C); /* clear the Ctrl-C signal */
  1501.             }
  1502.             if (aboutloop())
  1503.             {   CloseWindow(AboutWindowPtr);
  1504.                 AboutWindowPtr = NULL;
  1505.                 OnMenu(MainWindowPtr, FULLMENUNUM(MN_HELP, IN_ABOUT, NOSUB));
  1506.         }   }
  1507.         else
  1508.         {   if ((Wait(signal | SIGBREAKF_CTRL_C)) & SIGBREAKF_CTRL_C)
  1509.             {  done = TRUE;
  1510.                /* should we clear the Ctrl-C signal? */
  1511.         }   }
  1512.         if (page == 0)
  1513.         {   while ((result = DoMethod(Window0Object, WM_HANDLEINPUT, &code)) != WMHI_LASTMSG)
  1514.             {   switch (result & WMHI_CLASSMASK)
  1515.                 {
  1516.                 case WMHI_MENUPICK:
  1517.                     handlemenus(code);
  1518.                 break;
  1519.                 case WMHI_CLOSEWINDOW:
  1520.                     cleanexit(EXIT_SUCCESS);
  1521.                 break;
  1522.                 case WMHI_GADGETUP:
  1523.                     menu_loop(result & WMHI_GADGETMASK);
  1524.                 break;
  1525.                 default:
  1526.                 break;
  1527.         }   }   }
  1528.         elif (page == 121)
  1529.         {   while ((result = DoMethod(Window12Object, WM_HANDLEINPUT, &code)) != WMHI_LASTMSG)
  1530.             {   switch (result & WMHI_CLASSMASK)
  1531.                 {
  1532.                 case WMHI_MENUPICK:
  1533.                     handlemenus(code);
  1534.                 break;
  1535.                 case WMHI_CLOSEWINDOW:
  1536.                     page = 0;
  1537.                 break;
  1538.                 case WMHI_GADGETUP:
  1539.                     icon_loop(result & WMHI_GADGETMASK);
  1540.                 break;
  1541.                 default:
  1542.                 break;
  1543.         }   }   }
  1544.         else
  1545.         {   while (MsgPtr = (struct IntuiMessage *) GT_GetIMsg(MainWindowPtr->UserPort))
  1546.             {   class  = MsgPtr->Class;                       
  1547.                 code   = MsgPtr->Code;
  1548.                 addr   = MsgPtr->IAddress;
  1549.                 qual   = MsgPtr->Qualifier;
  1550.                 mousex = MsgPtr->MouseX;
  1551.                 mousey = MsgPtr->MouseY;
  1552.                 GT_ReplyIMsg(MsgPtr);
  1553.                 switch(class)
  1554.                 {
  1555.                 case IDCMP_MENUPICK:
  1556.                     handlemenus(code);
  1557.                 break;
  1558.                 case IDCMP_CLOSEWINDOW:
  1559.                     page = 0;
  1560.                 break;
  1561.                 case IDCMP_REFRESHWINDOW:
  1562.                     GT_BeginRefresh(MainWindowPtr);
  1563.                     GT_EndRefresh(MainWindowPtr, TRUE);
  1564.                 break;
  1565.                 default:
  1566.                     if (class == IDCMP_RAWKEY && code == SCAN_HELP)
  1567.                         helpabout();
  1568.                     elif (class == IDCMP_VANILLAKEY && code == ESCAPE && ((qual & IEQUALIFIER_LSHIFT) || (qual & IEQUALIFIER_RSHIFT)))
  1569.                         cleanexit(EXIT_SUCCESS);
  1570.                     elif (page >= 11 && page <= 14)
  1571.                         report_loop(class, addr, code, qual);
  1572.                     elif (page == 21)
  1573.                         aminet_loop(class, addr, code, qual);
  1574.                     elif (page >= 31 && page <= 33)
  1575.                         acse_loop(class, addr, code);
  1576.                     elif (page == 41)
  1577.                         autodoc_loop(class, addr, code);
  1578.                     elif (page == 51)
  1579.                         manuf_loop(class, addr, code);
  1580.                     elif (page == 61)
  1581.                         iff_loop(class, addr, code, qual);
  1582.                     elif (page == 71)
  1583.                         eol_loop(class, addr, code, qual);
  1584.                     elif (page == 81)
  1585.                         size_loop(class, addr, code, qual);
  1586.                     elif (page == 91)
  1587.                         batt_loop(class, addr, code, qual, mousex, mousey);
  1588.                     elif (page == 101)
  1589.                         files_loop(class, addr, code, qual);
  1590.                     elif (page == 111)
  1591.                     {   agdb_loop(class, addr, code);
  1592.                     }
  1593.                 break;
  1594. }   }   }   }   }
  1595.  
  1596. AGLOBAL void navigate(void)
  1597. {   gadtools();
  1598.  
  1599.     /* BU99_Right is created first, as all windows use it. Therefore all
  1600.     windows can safely call AddGList(), etc. with the BU99_Right argument. */
  1601.  
  1602.     /* next */
  1603.     switch(page)
  1604.     {
  1605.     case 11:
  1606.         setgadget(            10,  REPORTHEIGHT - 16,      REPORTWIDTH - 20, 12, "Menu",     NULL);
  1607.     break;
  1608.     case 12:
  1609.         setgadget(            10,  SENDERHEIGHT - 16,      SENDERWIDTH - 20, 12, "OK",     NULL);
  1610.     break;
  1611.     case 13:
  1612.         setgadget(            10,  CONFIGHEIGHT - 16,      CONFIGWIDTH - 20, 12, "OK",     NULL);
  1613.     break;
  1614.     case 21:
  1615.         setgadget(            10,  AMINETHEIGHT - 16,      AMINETWIDTH - 20, 12, "Menu",     NULL);
  1616.     break;
  1617.     case 31:
  1618.         setgadget(            10,   ACSE1HEIGHT - 16,       ACSE1WIDTH - 20, 12, "Menu",     NULL);
  1619.     break;
  1620.     case 32:
  1621.         if (certified)
  1622.             setgadget(        10,   ACSE2HEIGHT - 16,       ACSE2WIDTH - 20, 12, "OK",       NULL);
  1623.         else                                                                                 
  1624.             setgadget(        10,   ACSE2HEIGHT - 16,       ACSE2WIDTH - 20, 12, "Menu",     NULL);
  1625.     break;
  1626.     case 33:
  1627.         setgadget(            10,   ACSE3HEIGHT - 16,       ACSE3WIDTH - 20, 12, "Menu",     NULL);
  1628.     break;
  1629.     case 41:
  1630.         setgadget(            10, AUTODOCHEIGHT - 16,     AUTODOCWIDTH - 20, 12, "Menu",     NULL);
  1631.     break;
  1632.     case 51:
  1633.         setgadget(            10,  MANUF1HEIGHT - 16,      MANUF1WIDTH - 20, 12, "Menu",     NULL);
  1634.     break;
  1635.     case 61:
  1636.         setgadget(            10,    IFF1HEIGHT - 16,        IFF1WIDTH - 20, 12, "Menu",     NULL);
  1637.     break;
  1638.     case 71:
  1639.         setgadget(            10,    EOL1HEIGHT - 16,        EOL1WIDTH - 20, 12, "Menu",     NULL);
  1640.     break;
  1641.     case 81:
  1642.         if (ysize >= 512)
  1643.         {   setgadget(        10,           512 - 16,       SIZE1WIDTH - 20, 12, "Menu",     NULL);
  1644.         } else
  1645.         {   setgadget(        10,   SIZE1HEIGHT - 16,       SIZE1WIDTH - 20, 12, "Menu",     NULL);
  1646.         }
  1647.     break;
  1648.     case 91:
  1649.         setgadget(            10,   BATT1HEIGHT - 16,       BATT1WIDTH - 20, 12, "Menu",     NULL);
  1650.     break;
  1651.     case 101:
  1652.         setgadget(            10,  FILES1HEIGHT - 16,      FILES1WIDTH - 20, 12, "Menu",     NULL);
  1653.     break;
  1654.     case 111:
  1655.         setgadget(            10,    AGDBHEIGHT - 16,        AGDBWIDTH - 20, 12, "Menu",     NULL);
  1656.     break;
  1657.     default:
  1658.     break;
  1659.     }
  1660.     BU99_Right = PrevGadPtr = (struct Gadget *) CreateGadget
  1661.     (   BUTTON_KIND,
  1662.         PrevGadPtr,
  1663.         &Gadget,
  1664.         GT_Underscore, '_',
  1665.         TAG_DONE
  1666.     );
  1667. }
  1668.  
  1669. AGLOBAL void setgadget(WORD leftx, WORD topy, WORD width, WORD height,
  1670. STRPTR text, ULONG flags)
  1671. {   Gadget.ng_LeftEdge   = leftx;
  1672.     Gadget.ng_TopEdge    = topy;
  1673.     Gadget.ng_Width      = width;
  1674.     Gadget.ng_Height     = height;
  1675.     Gadget.ng_GadgetText = text;
  1676.     Gadget.ng_Flags      = flags;
  1677. }
  1678.  
  1679. AGLOBAL ABOOL readin(STRPTR pathname)
  1680. {   BPTR FileHandle;
  1681.  
  1682.     if (!(FileHandle = (BPTR) Open(pathname, MODE_OLDFILE)))
  1683.         return FALSE;
  1684.     if (Read(FileHandle, IOBuffer, 4096) == -1)
  1685.     /* the whole bug report must be < 4K */
  1686.     {   Close(FileHandle);
  1687.         return FALSE;
  1688.     }
  1689.     Close(FileHandle);
  1690.     return TRUE;
  1691. }
  1692.  
  1693. AGLOBAL void writeout(STRPTR pathname)
  1694. {   BPTR FileHandle;
  1695.  
  1696.     if (!(FileHandle = (BPTR) Open(pathname, MODE_NEWFILE)))
  1697.         rq("Can't open file for writing!");
  1698.     if (Write(FileHandle, IOBuffer, strlen(IOBuffer)) == -1)
  1699.     {   Close(FileHandle);
  1700.         rq("Can't write to file!");
  1701.     }
  1702.     Close(FileHandle);
  1703. }
  1704.  
  1705. AGLOBAL void launcheditor(STRPTR pathname)
  1706. {   GT_SetGadgetAttrs
  1707.     (   BU99_Right,
  1708.         MainWindowPtr, NULL,
  1709.         GA_Disabled, TRUE,
  1710.         TAG_DONE
  1711.     );
  1712.     textedit();
  1713.     GT_SetGadgetAttrs
  1714.     (   BU99_Right,
  1715.         MainWindowPtr, NULL,
  1716.         GA_Disabled, FALSE,
  1717.         TAG_DONE
  1718.     );
  1719. }
  1720.  
  1721. AGLOBAL void rq(STRPTR text)
  1722. {   EasyStruct.es_TextFormat = text;
  1723.     EasyRequest(MainWindowPtr, &EasyStruct, NULL);
  1724.  
  1725.     cleanexit(EXIT_FAILURE);
  1726. }
  1727.  
  1728. AGLOBAL void readordie(STRPTR pathname)
  1729. {   BPTR FileHandle;
  1730.  
  1731.     if (!(FileHandle = (BPTR) Open(pathname, MODE_OLDFILE)))
  1732.         rq("Can't open file for reading!");
  1733.     if (Read(FileHandle, IOBuffer, LONGESTFIELD) == -1)
  1734.     {   Close(FileHandle);
  1735.         rq("Can't read file!");
  1736.     }
  1737.     if (!Close(FileHandle))
  1738.         rq("Can't close file for reading!");
  1739. }
  1740.  
  1741. MODULE void parsewb(void)
  1742. {   struct DiskObject* DiskObject;
  1743.     STRPTR*            ToolArray;
  1744.     STRPTR             s;
  1745.  
  1746.     if ((*WBArg->wa_Name) && (DiskObject = GetDiskObject(WBArg->wa_Name)))
  1747.     {   ToolArray = (STRPTR *) DiskObject->do_ToolTypes;
  1748.  
  1749.         if (s = FindToolType((CONST_STRPTR *) ToolArray, "FILL"))
  1750.             fillwindows = TRUE;
  1751.         if (s = FindToolType((CONST_STRPTR *) ToolArray, "PUBSCREEN"))
  1752.             strcpy(pubscreen, s);
  1753.         if (s = FindToolType((CONST_STRPTR *) ToolArray, "ICONTYPE"))
  1754.         {   if (MatchToolValue(s, "DISK"))
  1755.             {   icon.type = WBDISK - 1;
  1756.             } elif (MatchToolValue(s, "DRAWER"))
  1757.             {   icon.type = WBDRAWER - 1;
  1758.             } elif (MatchToolValue(s, "TOOL"))
  1759.             {   icon.type = WBTOOL - 1;
  1760.             } elif (MatchToolValue(s, "PROJECT"))
  1761.             {   icon.type = WBPROJECT - 1;
  1762.             } elif (MatchToolValue(s, "TRASHCAN"))
  1763.             {   icon.type = WBGARBAGE - 1;
  1764.             } elif (MatchToolValue(s, "DEVICE"))
  1765.             {   icon.type = WBDEVICE - 1;
  1766.             } elif (MatchToolValue(s, "KICKSTART"))
  1767.             {   icon.type = WBKICK - 1;
  1768.             } elif (MatchToolValue(s, "APPICON"))
  1769.             {   icon.type = WBAPPICON - 1;
  1770.         }   }
  1771.         if (s = FindToolType((CONST_STRPTR *) ToolArray, "FUNCTION"))
  1772.         {   if (MatchToolValue(s, "1"))
  1773.                 page = 11;
  1774.             elif (MatchToolValue(s, "2"))
  1775.                 page = 21;
  1776.             elif (MatchToolValue(s, "3"))
  1777.                 page = 31;
  1778.             elif (MatchToolValue(s, "4"))
  1779.                 page = 41;
  1780.             elif (MatchToolValue(s, "5"))
  1781.                 page = 51;
  1782.             elif (MatchToolValue(s, "6"))
  1783.                 page = 61;
  1784.             elif (MatchToolValue(s, "7"))
  1785.                 page = 71;
  1786.             elif (MatchToolValue(s, "8"))
  1787.                 page = 81;
  1788.             elif (MatchToolValue(s, "9"))
  1789.                 page = 91;
  1790.             elif (MatchToolValue(s, "10"))
  1791.                 page = 101;
  1792.             elif (MatchToolValue(s, "11"))
  1793.             {   page = 111;
  1794.             } elif (MatchToolValue(s, "12"))
  1795.             {   page = 121;
  1796.         }   }
  1797.         FreeDiskObject(DiskObject);
  1798. }   }
  1799.  
  1800. AGLOBAL ULONG checkbreak(void)
  1801. {   struct IntuiMessage* MsgPtr;
  1802.     struct Gadget*       addr;
  1803.     ULONG                class;
  1804.     UWORD                code;
  1805.  
  1806.     while (MsgPtr = (struct IntuiMessage *) GT_GetIMsg(MainWindowPtr->UserPort))
  1807.     {   class  = MsgPtr->Class;
  1808.         code   = MsgPtr->Code;
  1809.         addr   = MsgPtr->IAddress;
  1810.         GT_ReplyIMsg((struct IntuiMessage *) MsgPtr);
  1811.         switch(class)
  1812.         {
  1813.         case IDCMP_CLOSEWINDOW:
  1814.             return(2);
  1815.         break;
  1816.         case IDCMP_GADGETUP:
  1817.             if (addr == BU99_Stop)
  1818.                 return(1);
  1819.         break;
  1820.         case IDCMP_VANILLAKEY:
  1821.             if (code == ESCAPE)
  1822.                 return(1);
  1823.         break;
  1824.         case IDCMP_REFRESHWINDOW:
  1825.             GT_BeginRefresh(MainWindowPtr);
  1826.             GT_EndRefresh(MainWindowPtr, TRUE);
  1827.         break;
  1828.         default:
  1829.         break;
  1830.     }   }
  1831.     return(0);
  1832. }
  1833.  
  1834. AGLOBAL void getdate(void)
  1835. {   struct DateTime DateTime;
  1836.  
  1837.     DateTime.dat_Format  = FORMAT_DOS;
  1838.     DateTime.dat_Flags   = NULL;
  1839.     DateTime.dat_StrDay  = weekdaystring;
  1840.     DateTime.dat_StrDate = datestring;
  1841.     DateTime.dat_StrTime = timestring;
  1842.  
  1843.     DateStamp(&(DateTime.dat_Stamp));
  1844.     if (!DateToStr(&DateTime))
  1845.         rq("Can't convert date!");
  1846. }
  1847.  
  1848. AGLOBAL void AddNameToTail(struct List* ListPtr, STRPTR name)
  1849. {   /* RKM Libraries, p. 496:
  1850.     
  1851.     "Allocate a NameNode structure, copy the given name into the
  1852.     structure, then add it [to] the...list." */
  1853.  
  1854.     struct NameNode* NameNodePtr;
  1855.  
  1856.     if (!(NameNodePtr = AllocMem(sizeof(struct NameNode), MEMF_CLEAR)))
  1857.         rq("Out of memory!");
  1858.     strcpy(NameNodePtr->nn_Data, name);
  1859.     NameNodePtr->nn_Node.ln_Name = NameNodePtr->nn_Data;
  1860.     NameNodePtr->nn_Node.ln_Type = NT_USER;
  1861.     NameNodePtr->nn_Node.ln_Pri  = 0;
  1862.     AddTail((struct List *) ListPtr, (struct Node *) NameNodePtr);
  1863. }
  1864.  
  1865. AGLOBAL void append(STRPTR pathname)
  1866. {   BPTR FileHandle;
  1867.  
  1868.     if (!(FileHandle = (BPTR) Open(pathname, MODE_READWRITE)))
  1869.         rq("Can't open file for appending!");
  1870.     Seek(FileHandle, 0, OFFSET_END);
  1871.     if (Write(FileHandle, IOBuffer, strlen(IOBuffer)) == -1)
  1872.     {   Close(FileHandle);
  1873.         rq("Can't append to file!");
  1874.     }
  1875.     if (!Close(FileHandle))
  1876.         rq("Can't close appended file!");
  1877. }
  1878.  
  1879. AGLOBAL ABOOL aboutloop(void)
  1880. {   struct IntuiMessage* MsgPtr;
  1881.     ABOOL                done = FALSE;
  1882.     UWORD                code, qual;
  1883.     ULONG                class;
  1884.  
  1885.     /* processes any outstanding messages for the About... window. */
  1886.     /* returns TRUE if user wants to exit, FALSE otherwise. */
  1887.  
  1888.     while (MsgPtr = (struct IntuiMessage *) GT_GetIMsg(AboutWindowPtr->UserPort))
  1889.     {   class = MsgPtr->Class;
  1890.         code  = MsgPtr->Code;
  1891.         qual  = MsgPtr->Qualifier;
  1892.         GT_ReplyIMsg(MsgPtr);
  1893.  
  1894.         if (class == CLOSEWINDOW)
  1895.             done = TRUE;
  1896.         elif (class == IDCMP_RAWKEY)
  1897.         {   if ((!(qual & IEQUALIFIER_REPEAT)) && code < KEYUP && (code < FIRSTQUALIFIER || code > LASTQUALIFIER))
  1898.                 done = TRUE;
  1899.     }   }
  1900.     return(done);
  1901. }
  1902.  
  1903. AGLOBAL void fliplog(ABOOL keyboard)
  1904. {   if (keyboard)
  1905.     {   if (CB99_Log->Flags & GFLG_SELECTED)
  1906.         {   shared.log = FALSE;
  1907.         } else
  1908.         {   shared.log = TRUE;
  1909.     }   }
  1910.     else
  1911.     {   if (CB99_Log->Flags & GFLG_SELECTED)
  1912.         {   shared.log = TRUE;
  1913.         } else
  1914.         {   shared.log = FALSE;
  1915.     }   }
  1916.  
  1917.     if (!shared.log)
  1918.     {   GT_SetGadgetAttrs
  1919.         (   ST99_Output,
  1920.             MainWindowPtr, NULL,
  1921.             GA_Disabled, TRUE,
  1922.             TAG_DONE
  1923.         );
  1924.         GT_SetGadgetAttrs
  1925.         (   BU99_OutputASL,
  1926.             MainWindowPtr, NULL,
  1927.             GA_Disabled, TRUE,
  1928.             TAG_DONE
  1929.         );
  1930.     } else
  1931.     {   GT_SetGadgetAttrs
  1932.         (   ST99_Output,
  1933.             MainWindowPtr, NULL,
  1934.             GA_Disabled, FALSE,
  1935.             TAG_DONE
  1936.         );
  1937.         GT_SetGadgetAttrs
  1938.         (   BU99_OutputASL,
  1939.             MainWindowPtr, NULL,
  1940.             GA_Disabled, FALSE,
  1941.             TAG_DONE
  1942.         );
  1943.     }
  1944.     GT_SetGadgetAttrs
  1945.     (   CB99_Log,
  1946.         MainWindowPtr, NULL,
  1947.         GTCB_Checked, shared.log,
  1948.         TAG_DONE
  1949.     );
  1950. }
  1951.  
  1952. AGLOBAL void outputasl(void)
  1953. {   asl();
  1954.     GT_SetGadgetAttrs
  1955.     (   ST99_Output,
  1956.         MainWindowPtr,
  1957.         NULL,
  1958.         GTST_String, aslresult,
  1959.         TAG_DONE
  1960.     );
  1961. }
  1962. AGLOBAL void outputstring(void)
  1963. {   strcpy
  1964.     (   shared.output,
  1965.         ((struct StringInfo *) ST99_Output->SpecialInfo)->Buffer
  1966.     );
  1967. }
  1968. AGLOBAL void drawgadgets(WORD gadgets)
  1969. {   if (!PrevGadPtr)
  1970.         rq("Can't create GadTools gadgets!");
  1971.     AddGList(MainWindowPtr, BU99_Right, (UWORD) ~0, gadgets, NULL);
  1972.     RefreshGList(BU99_Right, MainWindowPtr, NULL, -1);
  1973.     GT_RefreshWindow(MainWindowPtr, NULL);
  1974. }
  1975.  
  1976. AGLOBAL void parse(STRPTR terminator)
  1977. {   ABOOL done = FALSE;
  1978.     ULONG suboffset;
  1979.  
  1980.     suboffset = offset;
  1981.     while (!done)
  1982.     {   string[offset - suboffset] = IOBuffer[offset];
  1983.         if (!(strncmp(&(IOBuffer[offset]), terminator, strlen(terminator))))
  1984.         {   string[offset - suboffset] = 0;
  1985.             offset += strlen(terminator);
  1986.             done = TRUE;
  1987.         } elif (offset > strlen(IOBuffer))
  1988.         {   /* failure */
  1989.             string[0] = 0;
  1990.             done = TRUE;
  1991.         } else offset++;
  1992. }   }
  1993.  
  1994. AGLOBAL void parsetoend(void)
  1995. {   ABOOL done      = FALSE;
  1996.     ULONG suboffset = 0;
  1997.  
  1998.     while (!done)
  1999.     {   string[suboffset] = IOBuffer[offset];
  2000.         if (offset > strlen(IOBuffer))
  2001.         {   /* EOF */
  2002.             string[suboffset] = 0;
  2003.             done = TRUE;
  2004.         } else
  2005.         {   offset++;
  2006.             suboffset++;
  2007. }   }   }
  2008.  
  2009. AGLOBAL ABOOL saveasl(STRPTR message)
  2010. {   struct FileRequester* ASLRqPtr;
  2011.     TEXT                  tempstring[VLONGFIELD + 1];
  2012.     ABOOL                 success;
  2013.  
  2014.     strcpy(tempstring, "Report+: ");
  2015.     strcat(tempstring, message);
  2016.  
  2017.     if (!(ASLRqPtr = AllocAslRequestTags(ASL_FileRequest, ASL_Pattern, "~(#?.info)", ASL_Window, MainWindowPtr, TAG_DONE)))
  2018.         rq("Can't create ASL request!");
  2019.     if
  2020.     (   AslRequestTags(ASLRqPtr, ASL_Dir, asldir, ASL_Hail, tempstring, ASL_FuncFlags, FILF_PATGAD | FILF_SAVE, TAG_DONE)
  2021.      && *(ASLRqPtr->rf_File) != 0
  2022.     )
  2023.     {   strcpy(asldir, ASLRqPtr->rf_Dir);
  2024.         strcpy(aslresult, ASLRqPtr->rf_Dir);
  2025.         if (!AddPart(aslresult, ASLRqPtr->rf_File, VLONGFIELD))
  2026.             rq("Can't add filename to pathname!");
  2027.         success = TRUE;
  2028.     } else
  2029.     {   strcpy(asldir, "");
  2030.         strcpy(aslresult, "");
  2031.         success = FALSE;
  2032.     }
  2033.     if (ASLRqPtr) /* will always be true */
  2034.         FreeAslRequest(ASLRqPtr);
  2035.     return(success);
  2036. }
  2037.  
  2038. AGLOBAL void handlemenus(UWORD code)
  2039. {   /* struct MenuItem* ItemPtr; */
  2040.        BPTR             LockPtr;
  2041.  
  2042.     if (code != MENUNULL) /* while (code != MENUNULL) */
  2043.     {   /* ItemPtr = ItemAddress(MenuPtr, code); */
  2044.         switch (MENUNUM(code))
  2045.         {
  2046.         case MN_PROJECT:
  2047.             switch (ITEMNUM(code))
  2048.             {
  2049.             case IN_NEW:
  2050.                 if (page == 11)
  2051.                     newreport(TRUE);
  2052.                 elif (page == 21)
  2053.                     newaminet(TRUE);
  2054.                 elif (page == 41)
  2055.                     newautodoc(TRUE);
  2056.                 elif (page == 111)
  2057.                     newagdb(TRUE);
  2058.             break;
  2059.             case IN_OPEN:
  2060.                 if (page == 11)
  2061.                     openreport();
  2062.                 elif (page == 21)
  2063.                     openaminet();
  2064.                 elif (page == 41)
  2065.                     openautodoc();
  2066.                 elif (page == 91)
  2067.                 {   batt_open();
  2068.                 } elif (page == 111)
  2069.                     openagdb();
  2070.             break;
  2071.             case IN_SAVE:
  2072.                 if (page == 11)
  2073.                     savereport(FALSE);
  2074.                 elif (page == 21)
  2075.                     saveaminet(FALSE);
  2076.                 elif (page == 41)
  2077.                     saveautodoc(FALSE);
  2078.                 elif (page == 91)
  2079.                 {   batt_save(FALSE);
  2080.                 } elif (page == 111)
  2081.                     saveagdb(FALSE);
  2082.             break;
  2083.             case IN_SAVEAS:
  2084.                 if (page == 11)
  2085.                     savereport(TRUE);
  2086.                 elif (page == 21)
  2087.                     saveaminet(TRUE);
  2088.                 elif (page == 41)
  2089.                     saveautodoc(TRUE);
  2090.                 elif (page == 91)
  2091.                 {   batt_save(TRUE);
  2092.                 } elif (page == 111)
  2093.                     saveagdb(TRUE);
  2094.             break;
  2095.             case IN_QUIT:
  2096.                 cleanexit(EXIT_SUCCESS);
  2097.             break;
  2098.             default:
  2099.             break;
  2100.             }
  2101.         break;
  2102.         case MN_HELP:
  2103.             switch (ITEMNUM(code))
  2104.             {
  2105.             case IN_ABOUT:
  2106.                 helpabout();
  2107.             break;
  2108.             case IN_MANUAL:
  2109.                 LockPtr = Lock("CON:", ACCESS_READ);
  2110.                 if (SystemTags
  2111.                 (   "SYS:Utilities/MultiView ReportPlus.guide",
  2112.                     SYS_Input,  (ULONG) LockPtr,
  2113.                     SYS_Output, NULL,
  2114.                     SYS_Asynch, TRUE,
  2115.                     TAG_DONE
  2116.                 ) == -1)
  2117.                 {   DisplayBeep(ScreenPtr);
  2118.                 }
  2119.                 UnLock(LockPtr);
  2120.             break;
  2121.             default:
  2122.             break;
  2123.             }
  2124.         break;
  2125.         default:
  2126.         break;
  2127.         }
  2128.         /* Doing things the above way disables multi-selection,
  2129.         but prevents `endless selection'.
  2130.         code = ItemPtr->NextSelect; */
  2131. }   }
  2132.  
  2133. AGLOBAL void lockscreen(void)
  2134. {   if (pubscreen[0])
  2135.     {   if (!(ScreenPtr = LockPubScreen(pubscreen)))
  2136.         {   rq("Can't lock specified public screen!");
  2137.     }   }
  2138.     else
  2139.     {   if (!(ScreenPtr = LockPubScreen(NULL)))
  2140.         {   rq("Can't lock default public screen!");
  2141. }   }   }
  2142. AGLOBAL void unlockscreen(void)
  2143. {   if (ScreenPtr)
  2144.     {   if (pubscreen[0])
  2145.         {   UnlockPubScreen(pubscreen, ScreenPtr);
  2146.             ScreenPtr = NULL;
  2147.         } else
  2148.         {   UnlockPubScreen(NULL, ScreenPtr);
  2149.             ScreenPtr = NULL;
  2150. }   }   }
  2151.  
  2152. AGLOBAL void getfillcolour(void)
  2153. {   if (fillwindows)
  2154.     {   lockscreen();
  2155.         fillcolour = FindColor
  2156.         (   ScreenPtr->ViewPort.ColorMap,
  2157.             0x99999999, /* red */
  2158.             0x99999999, /* green */
  2159.             0xFFFFFFFF, /* blue */
  2160.            -1
  2161.         );
  2162.         unlockscreen();
  2163.     } else fillcolour = 0;
  2164. }
  2165.  
  2166. MODULE void eachwildcard(STRPTR subpattern)
  2167. {   struct AnchorPath* AnchorPathPtr;
  2168.     BPTR               OldDir;
  2169.     TEXT               dirbuffer[VLONGFIELD + 1];
  2170.     BOOL               result;
  2171.     ABOOL              done;
  2172.  
  2173.     dirbuffer[0] = NULL;
  2174.     if (!(AnchorPathPtr = AllocMem(sizeof(struct AnchorPath), MEMF_ANY | MEMF_PUBLIC)))
  2175.         return;
  2176.  
  2177.     AnchorPathPtr->ap_BreakBits = NULL;
  2178.     AnchorPathPtr->ap_Flags = NULL;
  2179.     AnchorPathPtr->ap_Strlen = 0;
  2180.     result = MatchFirst(subpattern, AnchorPathPtr);
  2181.     if (result == 0)
  2182.     {   OldDir = CurrentDir(AnchorPathPtr->ap_Current->an_Lock);
  2183.         if (!NameFromLock(AnchorPathPtr->ap_Current->an_Lock, dirbuffer, VLONGFIELD))
  2184.         {   MatchEnd(AnchorPathPtr);
  2185.             return;
  2186.         }
  2187.         if (!AddPart(dirbuffer, AnchorPathPtr->ap_Info.fib_FileName, VLONGFIELD))
  2188.         {   MatchEnd(AnchorPathPtr);
  2189.             return;
  2190.         }
  2191.         CurrentDir(OldDir);
  2192.         strcat(shared.finallist, "\"");
  2193.         strcat(shared.finallist, dirbuffer);
  2194.         strcat(shared.finallist, "\" ");
  2195.     } elif (result != ERROR_NO_MORE_ENTRIES)
  2196.     {   MatchEnd(AnchorPathPtr);
  2197.         return;
  2198.     }
  2199.  
  2200.     done = FALSE;
  2201.     while (!done)
  2202.     {   result = MatchNext(AnchorPathPtr);
  2203.         if (result == 0)
  2204.         {   OldDir = CurrentDir(AnchorPathPtr->ap_Current->an_Lock);
  2205.             if (!NameFromLock(AnchorPathPtr->ap_Current->an_Lock, dirbuffer, VLONGFIELD))
  2206.             {   MatchEnd(AnchorPathPtr);
  2207.                 return;
  2208.             }
  2209.             if (!AddPart(dirbuffer, AnchorPathPtr->ap_Info.fib_FileName, VLONGFIELD))
  2210.             {   MatchEnd(AnchorPathPtr);
  2211.                 return;
  2212.             }
  2213.             CurrentDir(OldDir);
  2214.             strcat(shared.finallist, "\"");
  2215.             strcat(shared.finallist, dirbuffer);
  2216.             strcat(shared.finallist, "\" ");
  2217.         } elif (result != ERROR_NO_MORE_ENTRIES)
  2218.         {   MatchEnd(AnchorPathPtr);
  2219.             return;
  2220.         } else done = TRUE;
  2221.     }
  2222.     MatchEnd(AnchorPathPtr);
  2223.     FreeMem(AnchorPathPtr, sizeof(struct AnchorPath));
  2224. }
  2225.  
  2226. AGLOBAL void multiasl(STRPTR pattern)
  2227. {   struct FileRequester* ASLRqPtr;
  2228.     ULONG                 i;
  2229.     TEXT                  quotestring[2];
  2230.  
  2231.     quotestring[0] = QUOTE;
  2232.     quotestring[1] = 0;
  2233.  
  2234.     /* It would also be good to correctly
  2235.     handle selection of directories. */
  2236.  
  2237.     if (!(ASLRqPtr = AllocAslRequestTags(ASL_FileRequest, ASL_Pattern, pattern, ASL_Window, MainWindowPtr, TAG_DONE)))
  2238.         rq("Can't create ASL request!");
  2239.     if (AslRequestTags(ASLRqPtr, ASL_Dir, asldir, ASL_Hail, "Report+ file multiselector", ASL_FuncFlags, FILF_PATGAD | FILF_MULTISELECT, TAG_DONE) && *(ASLRqPtr->rf_File) != 0)
  2240.     {   if (ASLRqPtr->rf_NumArgs)
  2241.         {   /* rf_ArgList is an array of WBArg structures. Each entry in
  2242.             this array corresponds to one of the files the user selected
  2243.             (in alphabetical order). The user multiselected; step through
  2244.             the list of selected files. */
  2245.  
  2246.             strcpy(asldir, ASLRqPtr->rf_Dir);
  2247.             strcpy(shared.pathname, quotestring);
  2248.             strcat(shared.pathname, ASLRqPtr->rf_Dir);
  2249.             if (!AddPart(shared.pathname, (ASLRqPtr->rf_ArgList)[0].wa_Name, VLONGFIELD))
  2250.                 rq("Can't add filename to pathname!");
  2251.             strcat(shared.pathname, quotestring);
  2252.             strcat(shared.pathname, " ");
  2253.             for (i = 1; i < ASLRqPtr->rf_NumArgs; i++)
  2254.             {   strcat(shared.pathname, quotestring);
  2255.                 strcat(shared.pathname, ASLRqPtr->rf_Dir);
  2256.                 if (!AddPart(shared.pathname, (ASLRqPtr->rf_ArgList)[i].wa_Name, VLONGFIELD))
  2257.                    rq("Can't add filename to pathname!");
  2258.                 strcat(shared.pathname, quotestring);
  2259.                 if (i < ASLRqPtr->rf_NumArgs - 1)
  2260.                     strcat(shared.pathname, " ");
  2261.         }   }
  2262.         else
  2263.         {   /* The user didn't multiselect; use the normal way to get the
  2264.             filename. */
  2265.  
  2266.             strcpy(shared.pathname, quotestring);
  2267.             strcat(shared.pathname, ASLRqPtr->rf_Dir);
  2268.             if (!AddPart(shared.pathname, ASLRqPtr->rf_File, VLONGFIELD))
  2269.                 rq("Can't add filename to pathname!");
  2270.             strcat(shared.pathname, quotestring);
  2271.     }   }
  2272.     if (ASLRqPtr)
  2273.         FreeAslRequest(ASLRqPtr);
  2274. }
  2275.  
  2276. AGLOBAL void checkabort(ABOOL gui)
  2277. {   struct Gadget*       addr;
  2278.     struct IntuiMessage* MsgPtr;
  2279.     ULONG                class, signals, gid, result;
  2280.     UWORD                code;
  2281.  
  2282.     /* OK, we've just finished operating on that file. Now before we */
  2283.     /* start on the next one, check whether the user still wants to... */
  2284.     signals = SetSignal(0L, 0L);
  2285.     if (signals & SIGBREAKF_CTRL_C)
  2286.     {   stop = TRUE;
  2287.         SetSignal(0L, SIGBREAKF_CTRL_C); /* clear the Ctrl-C signal */
  2288.         if (gui)
  2289.         {   if (page == 71)
  2290.             {   GT_SetGadgetAttrs
  2291.                 (   TE71_Status,
  2292.                     MainWindowPtr, NULL,
  2293.                     GTTX_Text, "Aborted by user!",
  2294.                     TAG_DONE
  2295.                 );
  2296.             } else
  2297.             {   /* assert(page == 121); */
  2298.                 SetGadgetAttrs
  2299.                 (   icon_gadgets[GID_12_ST2], MainWindowPtr, NULL,
  2300.                     STRINGA_TextVal, "Aborted by user!",
  2301.                     TAG_DONE
  2302.                 );
  2303.         }   }
  2304.         else
  2305.         {   Printf("Aborted by user!\n");
  2306.             Flush(Output());
  2307.     }   }
  2308.  
  2309.     if (page == 71)
  2310.     {
  2311.     while (MsgPtr = (struct IntuiMessage *) GT_GetIMsg(MainWindowPtr->UserPort))
  2312.     {   class  = MsgPtr->Class;                       
  2313.         addr   = MsgPtr->IAddress;
  2314.         GT_ReplyIMsg(MsgPtr);
  2315.         switch(class)
  2316.         {
  2317.         case IDCMP_CLOSEWINDOW:
  2318.             cleanexit(EXIT_SUCCESS);
  2319.         break;
  2320.         case IDCMP_GADGETUP:
  2321.             /* assert(gui); */
  2322.             if (addr == BU99_Stop)
  2323.             {   GT_SetGadgetAttrs
  2324.                 (   TE71_Status,
  2325.                     MainWindowPtr, NULL,
  2326.                     GTTX_Text, "Aborted by user!",
  2327.                     TAG_DONE
  2328.                 );
  2329.                 stop = TRUE;
  2330.             }
  2331.         break;
  2332.         default:
  2333.         break;
  2334.     }   }
  2335.     } else
  2336.     {   /* assert(page == 121); */
  2337.         while ((result = DoMethod(Window12Object, WM_HANDLEINPUT, &code)) != WMHI_LASTMSG)
  2338.         {   switch (result & WMHI_CLASSMASK)
  2339.             {
  2340.             case WMHI_MENUPICK:
  2341.                 ; /* handlemenus(code); */
  2342.             break;
  2343.             case WMHI_CLOSEWINDOW:
  2344.                 done = quit = TRUE;
  2345.             break;
  2346.             case WMHI_GADGETUP:
  2347.                 gid = result & WMHI_GADGETMASK;
  2348.                 if (gid == GID_12_BU4)
  2349.                 {   stop = TRUE;
  2350.                 }
  2351.             break;
  2352.             default:
  2353.             break;
  2354. }   }   }   }
  2355.  
  2356. AGLOBAL void convert(ABOOL gui)
  2357. {   ULONG i, j, length;
  2358.     ABOOL flag,   /* are we in letters (TRUE) or whitespace (FALSE)? */
  2359.           quoted; /* are we quoted (TRUE) or unquoted (FALSE)? */
  2360.  
  2361.     /* At this point we have a list of pathnames, separated by spaces and
  2362.     NULL-terminated. If they came from ASL, they will be quoted, otherwise,
  2363.     they may not.
  2364.  
  2365.     shared.pathname: the actual contents of the string gadget.
  2366.     shared.thatfile: each file that we pass to eachwildcard().
  2367.     shared.finallist: the final list produced, containing all pathnames.
  2368.     shared.thisfile: each file that we pass for conversion. */
  2369.  
  2370.     stop = flag = quoted = FALSE;
  2371.     length = strlen(shared.pathname);
  2372.     j = shared.finallist[0] = 0;
  2373.     for (i = 0; i < length; i++)
  2374.     {   if (shared.pathname[i] == ' ' && flag && !quoted)
  2375.         {   /* if we're unquoted and have a space */
  2376.             shared.thatfile[j] = 0; /* then NULL-terminate the pathname */
  2377.             eachwildcard(shared.thatfile);
  2378.             j = 0;
  2379.             flag = FALSE;
  2380.         } elif (shared.pathname[i] == QUOTE)
  2381.         {   if (!flag && !quoted)
  2382.             {   flag = TRUE; /* we're in letters */
  2383.                 quoted = TRUE; /* it's a quote */
  2384.             } elif (flag && quoted)
  2385.             {   quoted = FALSE; /* it's an unquote */
  2386.         }   }
  2387.         else
  2388.         {   shared.thatfile[j++] = shared.pathname[i];
  2389.             flag = TRUE; /* we're in letters */
  2390.     }   }
  2391.     /* Now we are at the end. */
  2392.     if (flag) /* if we're in letters */
  2393.     {   shared.thatfile[j] = 0;
  2394.         /* then it is ended, quoted or not. Although we could */
  2395.         /* report an error condition if there are an odd */
  2396.         /* number of quotes (ie. a missing quote). */
  2397.         eachwildcard(shared.thatfile);
  2398.     }
  2399.  
  2400.     flag = quoted = FALSE;
  2401.     length = strlen(shared.finallist);
  2402.     j = 0;
  2403.     for (i = 0; i < length; i++)
  2404.     {   if (shared.finallist[i] == ' ' && flag && !quoted)
  2405.         {   /* if we're unquoted and have a space */
  2406.             shared.thisfile[j] = 0; /* then NULL-terminate the pathname */
  2407.             if (!stop)
  2408.             {   if (shared.function == 7)
  2409.                 {   eolconvert(gui);
  2410.                 } else
  2411.                 {   /* assert(shared.function == 12); */
  2412.                     iconconvert(gui);
  2413.             }   }
  2414.             j = 0;
  2415.             flag = FALSE;
  2416.         } elif (shared.finallist[i] == QUOTE)
  2417.         {   if (!flag && !quoted)
  2418.             {   flag = TRUE; /* we're in letters */
  2419.                 quoted = TRUE; /* it's a quote */
  2420.             } elif (flag && quoted)
  2421.             {   quoted = FALSE; /* it's an unquote */
  2422.         }   }
  2423.         else
  2424.         {   shared.thisfile[j++] = shared.finallist[i];
  2425.             flag = TRUE; /* we're in letters */
  2426.         }
  2427.         if (stop)
  2428.         {   return;
  2429.     }   }
  2430.     /* Now we are at the end. */
  2431.     if (flag) /* if we're in letters */
  2432.     {   shared.thisfile[j] = 0;
  2433.         /* then it is ended, quoted or not. Although we could */
  2434.         /* report an error condition if there are an odd */
  2435.         /* number of quotes (ie. a missing quote). */
  2436.         if (shared.function == 7)
  2437.         {   eolconvert(gui);
  2438.         } else
  2439.         {   /* assert(shared.function == 12); */
  2440.             iconconvert(gui);
  2441. }   }   }
  2442.  
  2443. MODULE void menu_loop(ULONG gid)
  2444. {   switch (gid)
  2445.     {
  2446.     case GID_0_BU1:
  2447.         page = 11;  // bug report
  2448.     break;
  2449.     case GID_0_BU2:
  2450.         page = 21;  // Aminet readme
  2451.     break;
  2452.     case GID_0_BU3:
  2453.         page = 41;  // autodoc
  2454.     break;
  2455.     case GID_0_BU4:
  2456.         page = 91;  // battery RAM
  2457.     break;
  2458.     case GID_0_BU5:
  2459.         page = 111; // AGDB review
  2460.     break;
  2461.     case GID_0_BU6:
  2462.         page = 51;  // ID database
  2463.     break;
  2464.     case GID_0_BU7:
  2465.         page = 61;  // IFF FORMs
  2466.     break;
  2467.     case GID_0_BU8:
  2468.         page = 71;  // EOL/tabs
  2469.     break;
  2470.     case GID_0_BU9:
  2471.         page = 121; // icons
  2472.     break;
  2473.     case GID_0_BU10:
  2474.         page = 81;  // path size
  2475.     break;
  2476.     case GID_0_BU11:
  2477.         page = 101; // system files
  2478.     break;
  2479.     case GID_0_BU12:
  2480.         page = 31;  // ACSE
  2481.     break;
  2482.     default:
  2483.         ; // assert(0);
  2484.     break;
  2485. }   }
  2486.  
  2487. AGLOBAL ULONG Hook0Func(struct Hook *h, VOID *o, VOID *msg)
  2488. {   /* "When the hook is called, the data argument points to the 
  2489.     window object and message argument to the IntuiMessage."
  2490.  
  2491.     These IntuiMessages do not need to be replied to by the appliprog. */
  2492.  
  2493.     AUTO    UWORD code, qual;
  2494.     AUTO    ULONG class, i;
  2495.     AUTO    SWORD mousex, mousey;
  2496.     AUTO    SLONG newover;
  2497.     PERSIST ULONG over = FUNCTIONS;
  2498.  
  2499.     geta4(); // wait till here before doing anything
  2500.  
  2501.     class  = ((struct IntuiMessage *) msg)->Class;
  2502.     code   = ((struct IntuiMessage *) msg)->Code;
  2503.     qual   = ((struct IntuiMessage *) msg)->Qualifier;
  2504.     mousex = ((struct IntuiMessage *) msg)->MouseX;
  2505.     mousey = ((struct IntuiMessage *) msg)->MouseY;
  2506.  
  2507.     switch(class)
  2508.     {
  2509.     case IDCMP_RAWKEY:
  2510.         switch(code)
  2511.         {
  2512.         case SCAN_HELP:
  2513.             helpabout();
  2514.         break;
  2515.         case SCAN_ESCAPE:
  2516.             cleanexit(EXIT_SUCCESS);
  2517.         break;
  2518.         case SCAN_GRAVE:
  2519.             if (qual & IEQUALIFIER_CONTROL)
  2520.             {   decrypt();
  2521.             }
  2522.         break;
  2523.         default:
  2524.         break;
  2525.         }
  2526.     break;
  2527.     case IDCMP_INTUITICKS:
  2528.     {   newover = FUNCTIONS;
  2529.         for (i = 0; i < FUNCTIONS; i++)
  2530.         {   if
  2531.             (   mousex >= gadgets[GID_0_BU1 + i]->LeftEdge
  2532.              && mousex <= gadgets[GID_0_BU1 + i]->LeftEdge + gadgets[GID_0_BU1 + i]->Width  - 1
  2533.              && mousey >= gadgets[GID_0_BU1 + i]->TopEdge
  2534.              && mousey <= gadgets[GID_0_BU1 + i]->TopEdge  + gadgets[GID_0_BU1 + i]->Height - 1
  2535.             )
  2536.             {   newover = i;
  2537.                 break;
  2538.         }   }
  2539.         if (newover != over)
  2540.         {   over = newover;
  2541.             SetGadgetAttrs
  2542.             (   gadgets[GID_0_ST1], MainWindowPtr, NULL,
  2543.                 STRINGA_TextVal, FunctionDesc[over],
  2544.                 TAG_DONE
  2545.             );
  2546.     }   }
  2547.     break;
  2548.     default:
  2549.     break;
  2550.     }
  2551.  
  2552.     return(1);
  2553. }
  2554.  
  2555. /* This function converts register-parameter Hook calling convention into
  2556. standard C conventions. It requires a C compiler that supports
  2557. registerized parameters, such as SAS/C 5.x or greater. */
  2558.  
  2559. AGLOBAL ULONG ASM hookEntry(REG(a0) struct Hook *h, REG(a2) VOID *o, REG(a1) VOID *msg)
  2560. {   // This is the stub function that converts the register-parameters
  2561.     // to stack parameters.
  2562.  
  2563.     return ((*(ULONG (*)(struct Hook *, VOID *, VOID *))(*h->h_SubEntry))(h, o, msg));
  2564. }
  2565.  
  2566. AGLOBAL void InitHook(struct Hook* hook, ULONG (*func)(), void* data)
  2567. {   // Make sure a pointer was passed
  2568.  
  2569.     if (hook)
  2570.     {   // Fill in the Hook fields
  2571.         hook->h_Entry    = (ULONG (*)()) hookEntry;
  2572.         hook->h_SubEntry = func;
  2573.         hook->h_Data     = data;
  2574.     } else
  2575.     {   Printf("Report+: Can't initialize hook (NULL pointer)!");
  2576.         cleanexit(EXIT_FAILURE);
  2577. }   }
  2578.  
  2579. AGLOBAL void clearlist(struct List* ListPtr)
  2580. {   if (ListPtr->lh_Head->ln_Succ) // if list is non-empty
  2581.     {   FreeNameNodes(ListPtr);
  2582.     }
  2583.     NewList(ListPtr); // prepare for reuse
  2584. }
  2585.  
  2586. // Function to free an Exec List of ReAction ListBrowser nodes.
  2587. AGLOBAL void clearreactionlist(struct List* ListPtr)
  2588. {   /* Requirements: listbrowser class must be already open, and list
  2589.     must be detached from gadget*/
  2590.  
  2591.     if (ListPtr->lh_Head->ln_Succ) // if list is non-empty
  2592.     {   FreeListBrowserList(ListPtr);
  2593.     }
  2594.     NewList(ListPtr);
  2595. }
  2596.  
  2597. AGLOBAL void textedit(void)
  2598. {   struct MsgPort* AppPort        = NULL;
  2599.     struct Window*  TEWindowPtr    = NULL;
  2600.     Object*         TEWindowObject = NULL;
  2601.     TEXT            GadTitle[MAXELEMENTS + 1][VLONGFIELD + 1];
  2602.     ULONG           i, theindex, wrapsize;
  2603.     struct TagItem  windowtag[12],
  2604.                     rootlayouttag[7],
  2605.                     bothlayouttag[8],
  2606.                     supercaptiontag[8],
  2607.                     subcaptiontag[3],
  2608.                     texteditortag[4],
  2609.                     buttontag[4],
  2610.                      leftlayouttag[4 + (3 * (MAXELEMENTS + 1))],
  2611.                     rightlayouttag[4 + (3 * (MAXELEMENTS + 1))];
  2612.  
  2613.     if (page == 11)
  2614.     {   wrapsize = 75;
  2615.         switch(report.type)
  2616.         {
  2617.         case BUG:
  2618.             strcpy(GadTitle[0], "Brief bug description:");
  2619.             strcpy(GadTitle[1], "Bug generation procedure or example:");
  2620.             strcpy(GadTitle[2], "If this works differently on other versions or hardware, explain:");
  2621.             strcpy(GadTitle[3], "Related problems:");
  2622.             elements = 3;
  2623.         break;
  2624.         case COM:
  2625.             if (report.severity == 3)
  2626.             {   strcpy(GadTitle[0], "If this works differently on other versions or hardware, explain:");
  2627.                 elements = 0;
  2628.             } else
  2629.             {   strcpy(GadTitle[0], "Brief bug description:");
  2630.                 strcpy(GadTitle[1], "Bug generation procedure or example:");
  2631.                 strcpy(GadTitle[2], "If this works differently on other versions or hardware, explain:");
  2632.                 strcpy(GadTitle[3], "What developer is doing in that area of software or hardware:");
  2633.                 strcpy(GadTitle[4], "Related problems:");
  2634.                 elements = 4;
  2635.             }
  2636.         break;
  2637.         case ENH:
  2638.             strcpy(GadTitle[0], "Enhancement request:");
  2639.             elements = 0;
  2640.         break;
  2641.         default:
  2642.         break;
  2643.     }   }
  2644.     else
  2645.     {   // assert(page == 41);
  2646.         strcpy(GadTitle[0], "Function:");
  2647.  
  2648.         if (inputs)
  2649.         {   for (i = 1; i <= inputs; i++)
  2650.             {   strcpy(GadTitle[i], autodoc.var[i].name);
  2651.                 strcat(GadTitle[i], ":");
  2652.         }   }
  2653.         if (returncode)
  2654.         {   strcpy(GadTitle[inputs + 1], "Result:");
  2655.         }
  2656.         strcpy(GadTitle[inputs + 1 + returncode], "Example:");
  2657.         strcpy(GadTitle[inputs + 2 + returncode], "Notes:");
  2658.         strcpy(GadTitle[inputs + 3 + returncode], "Bugs:");
  2659.         strcpy(GadTitle[inputs + 4 + returncode], "See Also:");
  2660.         elements =      inputs + 4 + returncode;
  2661.         wrapsize = 72;
  2662.     }
  2663.  
  2664.     /* window
  2665.         root-layout
  2666.          both-layout
  2667.           left-layout
  2668.            super-caption
  2669.             sub-caption
  2670.            texteditor
  2671.           [right-layout
  2672.            super-caption
  2673.             sub-caption
  2674.            texteditor]
  2675.          button */
  2676.  
  2677.     if (AppPort = CreateMsgPort())
  2678.     {   /* Create the window object. */
  2679.  
  2680.         subcaptiontag[0].ti_Tag     = LABEL_Text;
  2681.         // subcaptiontag[0].ti_Data filled later
  2682.         subcaptiontag[1].ti_Tag     = LABEL_Justification;
  2683.         subcaptiontag[1].ti_Data    = LJ_CENTRE;
  2684.         subcaptiontag[2].ti_Tag     = TAG_END;
  2685.  
  2686.        texteditortag[0].ti_Tag  = GA_ID;
  2687.        // texteditortag[0].ti_Data filled later
  2688.        texteditortag[1].ti_Tag  = GA_RelVerify;
  2689.        texteditortag[1].ti_Data = TRUE;
  2690.        texteditortag[2].ti_Tag  = GA_TEXTEDITOR_ExportWrap;
  2691.        texteditortag[2].ti_Data = wrapsize;
  2692.        texteditortag[3].ti_Tag  = TAG_END;
  2693.  
  2694.      buttontag[0].ti_Tag      = GA_ID;
  2695.      buttontag[0].ti_Data     = GID_OK;
  2696.      buttontag[1].ti_Tag      = GA_RelVerify;
  2697.      buttontag[1].ti_Data     = TRUE;
  2698.      buttontag[2].ti_Tag      = GA_Text;
  2699.      buttontag[2].ti_Data     = (ULONG) "_OK";
  2700.      buttontag[3].ti_Tag      = TAG_END;
  2701.  
  2702.        supercaptiontag[0].ti_Tag  = LAYOUT_Orientation;
  2703.        supercaptiontag[0].ti_Data = LAYOUT_ORIENT_VERT;
  2704.        supercaptiontag[1].ti_Tag  = GA_BackFill;
  2705.        supercaptiontag[1].ti_Data = NULL;
  2706.        supercaptiontag[2].ti_Tag  = LAYOUT_SpaceOuter;
  2707.        supercaptiontag[2].ti_Data = TRUE;
  2708.        supercaptiontag[3].ti_Tag  = LAYOUT_VertAlignment;
  2709.        supercaptiontag[3].ti_Data = LALIGN_CENTER;
  2710.        supercaptiontag[4].ti_Tag  = LAYOUT_HorizAlignment;
  2711.        supercaptiontag[4].ti_Data = LALIGN_CENTER;
  2712.        supercaptiontag[5].ti_Tag  = LAYOUT_BevelStyle;
  2713.        supercaptiontag[5].ti_Data = BVS_FIELD;
  2714.        supercaptiontag[6].ti_Tag  = LAYOUT_AddImage;
  2715.        // supercaptiontag[6].ti_Data filled later
  2716.        supercaptiontag[7].ti_Tag  = TAG_END;
  2717.  
  2718.     leftlayouttag[0].ti_Tag  = LAYOUT_Orientation;
  2719.     leftlayouttag[0].ti_Data = LAYOUT_ORIENT_VERT;
  2720.     leftlayouttag[1].ti_Tag  = LAYOUT_SpaceOuter;
  2721.     leftlayouttag[1].ti_Data = TRUE;
  2722.     leftlayouttag[2].ti_Tag  = LAYOUT_DeferLayout;
  2723.     leftlayouttag[2].ti_Data = TRUE;
  2724.     theindex = 3;
  2725.  
  2726.     if (page == 41)
  2727.     {   for (i = 0; i <= elements / 2; i++)
  2728.         {   subcaptiontag[0].ti_Data          = (ULONG) GadTitle[i];
  2729.             texteditortag[0].ti_Data          = GID_TEXTEDITOR1 + i;
  2730.             supercaptiontag[6].ti_Data        = (ULONG) NewObjectA(LABEL_GetClass(), NULL, subcaptiontag);
  2731.             leftlayouttag[theindex].ti_Tag    = LAYOUT_AddChild;
  2732.             leftlayouttag[theindex++].ti_Data = (ULONG) NewObjectA(LAYOUT_GetClass(), NULL, supercaptiontag);
  2733.             leftlayouttag[theindex].ti_Tag    = CHILD_WeightedHeight;
  2734.             leftlayouttag[theindex++].ti_Data = 0;
  2735.             leftlayouttag[theindex].ti_Tag    = LAYOUT_AddChild;
  2736.             te_gadgets[GID_TEXTEDITOR1 + i]      = NewObjectA(TEXTEDITOR_GetClass(), NULL, texteditortag);
  2737.             leftlayouttag[theindex++].ti_Data = (ULONG) te_gadgets[GID_TEXTEDITOR1 + i];
  2738.         }
  2739.         leftlayouttag[theindex].ti_Tag        = TAG_END;
  2740.  
  2741.         rightlayouttag[0].ti_Tag  = LAYOUT_Orientation;
  2742.         rightlayouttag[0].ti_Data = LAYOUT_ORIENT_VERT;
  2743.         rightlayouttag[1].ti_Tag  = LAYOUT_SpaceOuter;
  2744.         rightlayouttag[1].ti_Data = TRUE;
  2745.         rightlayouttag[2].ti_Tag  = LAYOUT_DeferLayout;
  2746.         rightlayouttag[2].ti_Data = TRUE;
  2747.         theindex = 3;
  2748.         for (i = (elements / 2) + 1; i <= elements; i++)
  2749.         {   subcaptiontag[0].ti_Data           = (ULONG) GadTitle[i];
  2750.             texteditortag[0].ti_Data           = GID_TEXTEDITOR1 + i;
  2751.             supercaptiontag[6].ti_Data         = (ULONG) NewObjectA(LABEL_GetClass(), NULL, subcaptiontag);
  2752.             rightlayouttag[theindex].ti_Tag    = LAYOUT_AddChild;
  2753.             rightlayouttag[theindex++].ti_Data = (ULONG) NewObjectA(LAYOUT_GetClass(), NULL, supercaptiontag);
  2754.             rightlayouttag[theindex].ti_Tag    = CHILD_WeightedHeight;
  2755.             rightlayouttag[theindex++].ti_Data = 0;
  2756.             rightlayouttag[theindex].ti_Tag    = LAYOUT_AddChild;
  2757.             te_gadgets[GID_TEXTEDITOR1 + i]       = NewObjectA(TEXTEDITOR_GetClass(), NULL, texteditortag);
  2758.             rightlayouttag[theindex++].ti_Data = (ULONG) te_gadgets[GID_TEXTEDITOR1 + i];
  2759.         }
  2760.         rightlayouttag[theindex].ti_Tag        = TAG_END;
  2761.     } else
  2762.     {   for (i = 0; i <= elements; i++)
  2763.         {   subcaptiontag[0].ti_Data          = (ULONG) GadTitle[i];
  2764.             texteditortag[0].ti_Data          = GID_TEXTEDITOR1 + i;
  2765.             supercaptiontag[6].ti_Data        = (ULONG) NewObjectA(LABEL_GetClass(), NULL, subcaptiontag);
  2766.             leftlayouttag[theindex].ti_Tag    = LAYOUT_AddChild;
  2767.             leftlayouttag[theindex++].ti_Data = (ULONG) NewObjectA(LAYOUT_GetClass(), NULL, supercaptiontag);
  2768.             leftlayouttag[theindex].ti_Tag    = CHILD_WeightedHeight;
  2769.             leftlayouttag[theindex++].ti_Data = 0;
  2770.             leftlayouttag[theindex].ti_Tag    = LAYOUT_AddChild;
  2771.             te_gadgets[GID_TEXTEDITOR1 + i]      = NewObjectA(TEXTEDITOR_GetClass(), NULL, texteditortag);
  2772.             leftlayouttag[theindex++].ti_Data = (ULONG) te_gadgets[GID_TEXTEDITOR1 + i];
  2773.         }
  2774.         leftlayouttag[theindex].ti_Tag        = TAG_END;
  2775.     }
  2776.  
  2777.     /* The captions are as wide as required to hold the entire caption on
  2778.     one line. In many cases this means that `double-column' mode cannot be
  2779.     used, as the right column would be pushed out too far to the right,
  2780.     and partially offscreen. */
  2781.  
  2782.     bothlayouttag[0].ti_Tag  = LAYOUT_Orientation;
  2783.     bothlayouttag[0].ti_Data = LAYOUT_ORIENT_HORIZ;
  2784.     bothlayouttag[1].ti_Tag  = LAYOUT_SpaceOuter;
  2785.     bothlayouttag[1].ti_Data = TRUE;
  2786.     bothlayouttag[2].ti_Tag  = LAYOUT_DeferLayout;
  2787.     bothlayouttag[2].ti_Data = TRUE;
  2788.  
  2789.     bothlayouttag[3].ti_Tag  = LAYOUT_AddChild;
  2790.     bothlayouttag[3].ti_Data = (ULONG) NewObjectA(LAYOUT_GetClass(), NULL, leftlayouttag);
  2791.     bothlayouttag[4].ti_Tag  = CHILD_WeightedWidth;
  2792.     bothlayouttag[4].ti_Data = 50;
  2793.     if (page == 41)
  2794.     {   bothlayouttag[5].ti_Tag  = LAYOUT_AddChild;
  2795.         bothlayouttag[5].ti_Data = (ULONG) NewObjectA(LAYOUT_GetClass(), NULL, rightlayouttag);
  2796.         bothlayouttag[6].ti_Tag  = CHILD_WeightedWidth;
  2797.         bothlayouttag[6].ti_Data = 50;
  2798.         bothlayouttag[7].ti_Tag  = TAG_END;
  2799.     } else
  2800.         bothlayouttag[5].ti_Tag  = TAG_END;
  2801.  
  2802.         rootlayouttag[0].ti_Tag  = LAYOUT_Orientation;
  2803.         rootlayouttag[0].ti_Data = LAYOUT_ORIENT_VERT;
  2804.         rootlayouttag[1].ti_Tag  = LAYOUT_SpaceOuter;
  2805.         rootlayouttag[1].ti_Data = TRUE;
  2806.         rootlayouttag[2].ti_Tag  = LAYOUT_DeferLayout;
  2807.         rootlayouttag[2].ti_Data = TRUE;
  2808.         rootlayouttag[3].ti_Tag  = LAYOUT_AddChild;
  2809.         rootlayouttag[3].ti_Data = (ULONG) NewObjectA(LAYOUT_GetClass(), NULL, bothlayouttag);
  2810.         rootlayouttag[4].ti_Tag  = LAYOUT_AddChild;
  2811.         rootlayouttag[4].ti_Data = (ULONG) NewObjectA(NULL, "button.gadget", buttontag);
  2812.         rootlayouttag[5].ti_Tag  = CHILD_WeightedHeight;
  2813.         rootlayouttag[5].ti_Data = 0;
  2814.         rootlayouttag[6].ti_Tag  = TAG_END;
  2815.  
  2816.         lockscreen();
  2817.         windowtag[0].ti_Tag   = WA_PubScreen;
  2818.         windowtag[0].ti_Data  = (ULONG) ScreenPtr;
  2819.         windowtag[1].ti_Tag   = WA_ScreenTitle;
  2820.         windowtag[1].ti_Data  = (ULONG) "Report+";
  2821.         windowtag[2].ti_Tag   = WA_Title;
  2822.         windowtag[2].ti_Data  = (ULONG) "Report+: Text Editor";
  2823.         windowtag[3].ti_Tag   = WA_Activate;
  2824.         windowtag[3].ti_Data  = TRUE;
  2825.         windowtag[4].ti_Tag   = WA_DepthGadget;
  2826.         windowtag[4].ti_Data  = TRUE;
  2827.         windowtag[5].ti_Tag   = WA_DragBar;
  2828.         windowtag[5].ti_Data  = TRUE;
  2829.         windowtag[6].ti_Tag   = WA_CloseGadget;
  2830.         windowtag[6].ti_Data  = TRUE;
  2831.         windowtag[7].ti_Tag   = WA_SizeGadget;
  2832.         windowtag[7].ti_Data  = TRUE;
  2833.         windowtag[8].ti_Tag   = WINDOW_AppPort;
  2834.         windowtag[8].ti_Data  = (ULONG) AppPort;
  2835.         windowtag[9].ti_Tag   = WINDOW_Position;
  2836.         windowtag[9].ti_Data  = WPOS_FULLSCREEN;
  2837.         windowtag[10].ti_Tag  = WINDOW_ParentGroup;
  2838.         te_gadgets[GID_MAIN]     = NewObjectA(LAYOUT_GetClass(), NULL, rootlayouttag);
  2839.         windowtag[10].ti_Data = (ULONG) te_gadgets[GID_MAIN];
  2840.         windowtag[11].ti_Tag  = TAG_END;
  2841.  
  2842.         TEWindowObject = NewObjectA(WINDOW_GetClass(), NULL, windowtag);
  2843.         unlockscreen();
  2844.  
  2845.         // Object creation successful?
  2846.         if (TEWindowObject)
  2847.         {   // Open the window.
  2848.             if (TEWindowPtr = (struct Window *) DoMethod(TEWindowObject, WM_OPEN, NULL))
  2849.             {   ULONG wait, signal, app = (1L << AppPort->mp_SigBit);
  2850.                 ULONG result;
  2851.                 UWORD code;
  2852.  
  2853.                 done = FALSE;
  2854.  
  2855.                 // Obtain the window wait signal mask.
  2856.                 GetAttr(WINDOW_SigMask, TEWindowObject, &signal);
  2857.  
  2858.                 // Do any necessary imports.
  2859.                 if (page == 11)
  2860.                 {   switch(report.type)
  2861.                     {
  2862.                     case BUG:
  2863.                         SetGadgetAttrs
  2864.                         (   te_gadgets[GID_TEXTEDITOR1],       TEWindowPtr, NULL,
  2865.                             GA_TEXTEDITOR_Contents,         report.textfield[0]
  2866.                         ); // brief bug description
  2867.                         SetGadgetAttrs
  2868.                         (   te_gadgets[GID_TEXTEDITOR1 + 1],   TEWindowPtr, NULL,
  2869.                             GA_TEXTEDITOR_Contents,         report.textfield[1]
  2870.                         ); // bug generation procedure or example
  2871.                         SetGadgetAttrs
  2872.                         (   te_gadgets[GID_TEXTEDITOR1 + 2],   TEWindowPtr, NULL,
  2873.                             GA_TEXTEDITOR_Contents,         report.textfield[2]
  2874.                         ); // if this works differently...
  2875.                         SetGadgetAttrs
  2876.                         (   te_gadgets[GID_TEXTEDITOR1 + 3],   TEWindowPtr, NULL,
  2877.                             GA_TEXTEDITOR_Contents,         report.textfield[3]
  2878.                         ); // related problems
  2879.                     break;
  2880.                     case COM:
  2881.                         if (report.severity == 0)
  2882.                         {   SetGadgetAttrs
  2883.                             (   te_gadgets[GID_TEXTEDITOR1],   TEWindowPtr, NULL,
  2884.                                 GA_TEXTEDITOR_Contents,     report.textfield[2]
  2885.                             ); // if this works differently...
  2886.                         } else
  2887.                         {   for (i = 0; i <= 4; i++)
  2888.                             {   SetGadgetAttrs
  2889.                                 (   te_gadgets[GID_TEXTEDITOR1 + i], TEWindowPtr, NULL,
  2890.                                     GA_TEXTEDITOR_Contents,       report.textfield[i]
  2891.                                 );
  2892.                         }   }
  2893.                         /* brief bug description
  2894.                            bug generation procedure or example
  2895.                            if this works differently...
  2896.                            what developer is doing...
  2897.                            related problems */
  2898.                     break;
  2899.                     case ENH:
  2900.                         SetGadgetAttrs
  2901.                         (   te_gadgets[GID_TEXTEDITOR1],       TEWindowPtr, NULL,
  2902.                             GA_TEXTEDITOR_Contents,         report.textfield[5]
  2903.                         ); // enhancement request
  2904.                     break;
  2905.                     default:
  2906.                         ; // assert(0);
  2907.                     break;
  2908.                 }   }
  2909.                 else
  2910.                 {   // assert(page == 41);
  2911.                     /* Autodoc text fields are as follows:
  2912.                      0 Function
  2913.                      1 Example
  2914.                      2 Notes
  2915.                      3 Bugs
  2916.                      4 See also
  2917.                      5 Result   (mirrors autodoc.var[0].desc)
  2918.                   6-13 Inputs   (
  2919.  
  2920.                     Whereas the te_gadgets go Function, inputs, Result, others
  2921.  
  2922.                     */
  2923.  
  2924.                     SetGadgetAttrs
  2925.                     (   te_gadgets[GID_TEXTEDITOR1],       TEWindowPtr, NULL,
  2926.                         GA_TEXTEDITOR_Contents,         autodoc.textfield[0]
  2927.                     );
  2928.  
  2929.                     if (inputs)
  2930.                     {   for (i = 1; i < inputs; i++)
  2931.                         {   SetGadgetAttrs
  2932.                             (   te_gadgets[GID_TEXTEDITOR1 + i], TEWindowPtr, NULL,
  2933.                                 GA_TEXTEDITOR_Contents, autodoc.var[i].desc
  2934.                             );
  2935.                     }   }
  2936.                     if (returncode)
  2937.                     {   SetGadgetAttrs
  2938.                         (   te_gadgets[GID_TEXTEDITOR1 + inputs + 1], TEWindowPtr, NULL,
  2939.                             GA_TEXTEDITOR_Contents,     autodoc.var[0].desc
  2940.                         ); // return code
  2941.                     }
  2942.                     for (i = 1; i <= 4; i++)
  2943.                     {   SetGadgetAttrs
  2944.                         (   te_gadgets[GID_TEXTEDITOR1 + inputs + returncode + i], TEWindowPtr, NULL,
  2945.                             GA_TEXTEDITOR_Contents,     autodoc.textfield[i]
  2946.                         );
  2947.                 }   }
  2948.  
  2949.                 // Activate the first texteditor gadget.
  2950.                 ActivateLayoutGadget(te_gadgets[GID_MAIN], TEWindowPtr, NULL, (Object) te_gadgets[GID_TEXTEDITOR1]);
  2951.  
  2952.                 // Input Event Loop
  2953.                 while (!done)
  2954.                 {   wait = Wait( signal | SIGBREAKF_CTRL_C | app );
  2955.  
  2956.                     if ( wait & SIGBREAKF_CTRL_C )
  2957.                         done = TRUE;
  2958.                     else
  2959.                     {   while ( (result = RA_HandleInput(TEWindowObject, &code) ) != WMHI_LASTMSG )
  2960.                         {   switch (result & WMHI_CLASSMASK)
  2961.                             {
  2962.                             case WMHI_CLOSEWINDOW:
  2963.                                 TEWindowPtr = NULL;
  2964.                                 done = TRUE;
  2965.                             break;
  2966.                             case WMHI_GADGETUP:
  2967.                                 switch (result & WMHI_GADGETMASK)
  2968.                                 {
  2969.                                 case GID_OK:
  2970.                                     done = TRUE;
  2971.                                 break;
  2972.                                 default:
  2973.                                 break;
  2974.                                 }
  2975.                             break;
  2976.                             default:
  2977.                             break;
  2978.             }   }   }   }   }
  2979.  
  2980.             for (i = 0; i <= elements; i++)
  2981.                 textBuffer[i] = (STRPTR) DoGadgetMethod(te_gadgets[GID_TEXTEDITOR1 + i], TEWindowPtr, NULL, GM_TEXTEDITOR_ExportText, NULL);
  2982.  
  2983.             if (page == 11)
  2984.             {   switch(report.type)
  2985.                 {
  2986.                 case BUG:
  2987.                     strcpy(report.textfield[0], textBuffer[0]); // brief bug description
  2988.                     strcpy(report.textfield[1], textBuffer[1]); // bug generation procedure or example
  2989.                     strcpy(report.textfield[2], textBuffer[2]); // if this works differently...
  2990.                     strcpy(report.textfield[4], textBuffer[3]); // related problems
  2991.                 break;
  2992.                 case COM:
  2993.                     if (report.severity == 0)
  2994.                     {   strcpy(report.textfield[2], textBuffer[0]); // if this works differently...
  2995.                     } else
  2996.                     {   strcpy(report.textfield[0], textBuffer[0]); // brief bug description
  2997.                         strcpy(report.textfield[1], textBuffer[1]); // bug generation procedure or example
  2998.                         strcpy(report.textfield[2], textBuffer[2]); // if this works differently...
  2999.                         strcpy(report.textfield[3], textBuffer[3]); // what developer is doing...
  3000.                         strcpy(report.textfield[4], textBuffer[4]); // related problems
  3001.                     }
  3002.                 break;
  3003.                 case ENH:
  3004.                     strcpy(report.textfield[5], textBuffer[0]); // enhancement request
  3005.                 break;
  3006.                 default:
  3007.                     ; // assert(0);
  3008.                 break;
  3009.             }   }
  3010.             else
  3011.             {   // assert(page == 41);
  3012.                 strcpy(autodoc.textfield[0], textBuffer[0]); // function
  3013.                 if (inputs)
  3014.                 {   for (i = 1; i <= inputs; i++)
  3015.                     {   strcpy(autodoc.var[i].desc, textBuffer[i]);
  3016.                 }   }
  3017.                 if (returncode)
  3018.                 {   strcpy(autodoc.var[0].desc, textBuffer[inputs + 1]);
  3019.                 }
  3020.                 for (i = 1; i <= 4; i++)
  3021.                 {   strcpy(autodoc.textfield[i], textBuffer[inputs + returncode + i]);
  3022.                 }
  3023.  
  3024.                 /* Qty  Field type
  3025.                      1  Function field
  3026.                    0-8  Input # fields
  3027.                 0 or 1  Return code field
  3028.                      1  Example field
  3029.                      1  Notes field
  3030.                      1  Bugs field
  3031.                      1  See also field */
  3032.             }
  3033.  
  3034.             for (i = 0; i <= elements; i++)
  3035.             {   FreeVec((APTR) textBuffer[i]);
  3036.                 textBuffer[i] = NULL;
  3037.             }
  3038.     
  3039.             /* Disposing of the window object will also close the window if it is
  3040.              * already opened, and it will dispose of the layout object attached to it.
  3041.              */
  3042.             DisposeObject(TEWindowObject);
  3043.         } else rq("Report+: Can't create ReAction objects!");
  3044.         DeleteMsgPort(AppPort);
  3045.     } else rq("Report+: Can't create window message port!");
  3046.  
  3047.     return;
  3048. }
  3049.  
  3050.